bump
This commit is contained in:
parent
04a7413f0f
commit
1161fe551e
35 changed files with 1957 additions and 2 deletions
|
@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx1G
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# More versions available at: https://grayray75.github.io/LegacyFabric-Versions/
|
# More versions available at: https://grayray75.github.io/LegacyFabric-Versions/
|
||||||
minecraft_version = 1.7.10
|
minecraft_version = 1.7.10
|
||||||
yarn_build = 532
|
yarn_build = 533
|
||||||
loader_version = 0.14.22
|
loader_version = 0.14.24
|
||||||
|
|
||||||
# Legacy Fabric API
|
# Legacy Fabric API
|
||||||
# Also available for mc 1.7.10, 1.8, 1.9.4, 1.10.2, 1.11.2 and 1.12.2
|
# Also available for mc 1.7.10, 1.8, 1.9.4, 1.10.2, 1.11.2 and 1.12.2
|
||||||
|
|
42
remappedSrc/xyz/limepot/emb/EMB.java
Normal file
42
remappedSrc/xyz/limepot/emb/EMB.java
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
package xyz.limepot.emb;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import xyz.limepot.emb.advancement.ModAchievements;
|
||||||
|
import xyz.limepot.emb.block.ModBlocks;
|
||||||
|
import xyz.limepot.emb.client.sound.ModSounds;
|
||||||
|
import xyz.limepot.emb.config.ModConfigs;
|
||||||
|
import xyz.limepot.emb.entity.ModStatusEffects;
|
||||||
|
import xyz.limepot.emb.item.ModItems;
|
||||||
|
import xyz.limepot.emb.recipe.ModCraftingRecipes;
|
||||||
|
import xyz.limepot.emb.recipe.ModSemltingRecipes;
|
||||||
|
|
||||||
|
|
||||||
|
public class EMB implements ModInitializer {
|
||||||
|
|
||||||
|
//Mod ID
|
||||||
|
public static final String MOD_ID = "emb";
|
||||||
|
public static final String MOD_VER = "0.1.3-dev";
|
||||||
|
//Initialize Logger
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger("Even More Bountiful");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInitialize() {
|
||||||
|
//REGISTRIES
|
||||||
|
ModConfigs.registerConfigs();
|
||||||
|
|
||||||
|
ModStatusEffects.registerModStatusEffects();
|
||||||
|
ModBlocks.registerModBlocks();
|
||||||
|
ModItems.registerModItems();
|
||||||
|
|
||||||
|
ModSemltingRecipes.registerModSmeltingRecipes();
|
||||||
|
ModCraftingRecipes.registerModRecipes();
|
||||||
|
|
||||||
|
if(ModConfigs.ENABLE_ACHIEVEMENTS){ModAchievements.registerModAchievements();}
|
||||||
|
|
||||||
|
ModSounds.registerModSounds();
|
||||||
|
|
||||||
|
LOGGER.info("Hello Legacy Fabric World from " + MOD_ID + "!");
|
||||||
|
}
|
||||||
|
}
|
11
remappedSrc/xyz/limepot/emb/EMBClient.java
Normal file
11
remappedSrc/xyz/limepot/emb/EMBClient.java
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package xyz.limepot.emb;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
|
||||||
|
public class EMBClient implements ClientModInitializer {
|
||||||
|
@Override
|
||||||
|
public void onInitializeClient()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
19
remappedSrc/xyz/limepot/emb/advancement/ModAchievements.java
Normal file
19
remappedSrc/xyz/limepot/emb/advancement/ModAchievements.java
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package xyz.limepot.emb.advancement;
|
||||||
|
|
||||||
|
import net.minecraft.advancement.Achievement;
|
||||||
|
import xyz.limepot.emb.EMB;
|
||||||
|
import xyz.limepot.emb.config.ModConfigs;
|
||||||
|
import xyz.limepot.emb.item.ModItems;
|
||||||
|
|
||||||
|
import static net.minecraft.advancement.AchievementsAndCriterions.ACQUIRE_IRON;
|
||||||
|
import static net.minecraft.advancement.AchievementsAndCriterions.BUILD_FURNACE;
|
||||||
|
|
||||||
|
public class ModAchievements {
|
||||||
|
|
||||||
|
public static Achievement BURY_ME_WITH_MY_MONEY = new Achievement("achievement.getMoney", "getMoney", 1, 6, ModItems.GOLD_COIN, ACQUIRE_IRON).addStat();
|
||||||
|
|
||||||
|
public static void registerModAchievements() {
|
||||||
|
EMB.LOGGER.debug("Registering Achievements....");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
6
remappedSrc/xyz/limepot/emb/block/CustomFlowerBlock.java
Normal file
6
remappedSrc/xyz/limepot/emb/block/CustomFlowerBlock.java
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
package xyz.limepot.emb.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.PlantBlock;
|
||||||
|
|
||||||
|
public class CustomFlowerBlock extends PlantBlock {
|
||||||
|
}
|
20
remappedSrc/xyz/limepot/emb/block/IronButtonBlock.java
Normal file
20
remappedSrc/xyz/limepot/emb/block/IronButtonBlock.java
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package xyz.limepot.emb.block;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.block.AbstractButtonBlock;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.client.Texture;
|
||||||
|
|
||||||
|
public class IronButtonBlock extends AbstractButtonBlock {
|
||||||
|
protected IronButtonBlock() {
|
||||||
|
super(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
@Override
|
||||||
|
public Texture getTexture(int side, int blockData) {
|
||||||
|
return Blocks.IRON_BLOCK.getSideTexture(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
36
remappedSrc/xyz/limepot/emb/block/ModBlocks.java
Normal file
36
remappedSrc/xyz/limepot/emb/block/ModBlocks.java
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
package xyz.limepot.emb.block;
|
||||||
|
|
||||||
|
import net.legacyfabric.fabric.api.util.Identifier;
|
||||||
|
import net.legacyfabric.fabric.impl.registry.RegistryHelperImpl;
|
||||||
|
import net.minecraft.block.*;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.item.BlockItem;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.itemgroup.ItemGroup;
|
||||||
|
import xyz.limepot.emb.EMB;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.minecraft.block.Block.STONE_SOUND_GROUP;
|
||||||
|
import static xyz.limepot.emb.EMB.MOD_ID;
|
||||||
|
|
||||||
|
public class ModBlocks {
|
||||||
|
|
||||||
|
//public static final Block CYAN_ROSE = registerBlock(new FlowerBlock(0).setStrength(0.0F).setBlockSoundGroup(GRASS_SOUND_GROUP).setItemGroup(ItemGroup.DECORATIONS).setTranslationKey("cyan_flower"), "cyan_rose");
|
||||||
|
public static final Block CYAN_ROSE = registerBlock(new CustomFlowerBlock().method_5546("cyan_rose").setBlockSoundGroup(Block.GRASS_SOUND_GROUP).setStrength(0.0F).setItemGroup(ItemGroup.DECORATIONS), "cyan_rose");
|
||||||
|
//public static final Block CYAN_ROSE_BUSH = registerBlock(new TallPlantBlock().method_5546("cyan_rose_bush").setBlockSoundGroup(Block.GRASS_SOUND_GROUP).setStrength(0.0F).setItemGroup(ItemGroup.DECORATIONS), "cyan_rose_bush");
|
||||||
|
public static final Block IRON_BUTTON = registerBlock(new IronButtonBlock().method_5546("iron_button").setStrength(0.5F).setBlockSoundGroup(STONE_SOUND_GROUP), "iron_button");
|
||||||
|
public static final Block ROPE = registerBlock(new RopeBlock().method_5546("rope").setStrength(0.4F), "rope");
|
||||||
|
public static final Block STOVE_BLOCK = registerBlock(new StoveBlock(false).method_5546("stove_block").setStrength(3.5F).setBlockSoundGroup(STONE_SOUND_GROUP).setItemGroup(ItemGroup.DECORATIONS), "stove_block");
|
||||||
|
public static final Block LIT_STOVE_BLOCK = registerBlock(new StoveBlock(true).method_5546("lit_stove_block").setLightLevel(0.875F).setStrength(3.5F).setBlockSoundGroup(STONE_SOUND_GROUP).setItemGroup(ItemGroup.DECORATIONS), "lit_stove_block");
|
||||||
|
|
||||||
|
public static final Block PALM_LOG_BLOCK = registerBlock(new ModLogBlock().method_5546("palm_log"), "palm_log");
|
||||||
|
|
||||||
|
public static Block registerBlock(Block block, String name) {
|
||||||
|
return RegistryHelperImpl.registerBlock(block, new Identifier(MOD_ID, name));
|
||||||
|
}
|
||||||
|
public static void registerModBlocks() {EMB.LOGGER.debug("Registering Blocks....");
|
||||||
|
}
|
||||||
|
}
|
6
remappedSrc/xyz/limepot/emb/block/ModLogBlock.java
Normal file
6
remappedSrc/xyz/limepot/emb/block/ModLogBlock.java
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
package xyz.limepot.emb.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.LogBlock;
|
||||||
|
|
||||||
|
public class ModLogBlock extends LogBlock {
|
||||||
|
}
|
6
remappedSrc/xyz/limepot/emb/block/RopeBlock.java
Normal file
6
remappedSrc/xyz/limepot/emb/block/RopeBlock.java
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
package xyz.limepot.emb.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.LadderBlock;
|
||||||
|
|
||||||
|
public class RopeBlock extends LadderBlock {
|
||||||
|
}
|
243
remappedSrc/xyz/limepot/emb/block/StoveBlock.java
Normal file
243
remappedSrc/xyz/limepot/emb/block/StoveBlock.java
Normal file
|
@ -0,0 +1,243 @@
|
||||||
|
package xyz.limepot.emb.block;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockWithEntity;
|
||||||
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.client.Texture;
|
||||||
|
import net.minecraft.client.TextureRegistry;
|
||||||
|
import net.minecraft.entity.ItemEntity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.inventory.Inventory;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.itemgroup.ItemGroup;
|
||||||
|
import net.minecraft.nbt.NbtCompound;
|
||||||
|
import net.minecraft.screen.ScreenHandler;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import xyz.limepot.emb.block.entity.StoveBlockEntity;
|
||||||
|
import xyz.limepot.emb.entity.player.PlayerEntity;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class StoveBlock extends BlockWithEntity {
|
||||||
|
private final Random random = new Random();
|
||||||
|
private final boolean isLit;
|
||||||
|
private static boolean keepInventory;
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
private Texture texture1;
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
private Texture texture2;
|
||||||
|
|
||||||
|
protected StoveBlock(boolean bl) {
|
||||||
|
super(Material.STONE);
|
||||||
|
this.isLit = bl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Item method_398(int i, Random random, int j) {
|
||||||
|
return Item.fromBlock(ModBlocks.STOVE_BLOCK).setItemGroup(ItemGroup.DECORATIONS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void breakNaturally(World world, int x, int y, int z) {
|
||||||
|
super.breakNaturally(world, x, y, z);
|
||||||
|
this.method_322(world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void method_322(World world, int i, int j, int k) {
|
||||||
|
if (!world.isClient) {
|
||||||
|
Block var5 = world.getBlock(i, j, k - 1);
|
||||||
|
Block var6 = world.getBlock(i, j, k + 1);
|
||||||
|
Block var7 = world.getBlock(i - 1, j, k);
|
||||||
|
Block var8 = world.getBlock(i + 1, j, k);
|
||||||
|
byte var9 = 3;
|
||||||
|
if (var5.isFullBlock() && !var6.isFullBlock()) {
|
||||||
|
var9 = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var6.isFullBlock() && !var5.isFullBlock()) {
|
||||||
|
var9 = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var7.isFullBlock() && !var8.isFullBlock()) {
|
||||||
|
var9 = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var8.isFullBlock() && !var7.isFullBlock()) {
|
||||||
|
var9 = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
world.method_4718(i, j, k, var9, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
@Override
|
||||||
|
public Texture getTexture(int side, int blockData) {
|
||||||
|
if (side == 1) {
|
||||||
|
return this.texture1;
|
||||||
|
} else if (side == 0) {
|
||||||
|
return this.texture1;
|
||||||
|
} else {
|
||||||
|
return side != blockData ? this.side : this.texture2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
@Override
|
||||||
|
public void registerTextures(TextureRegistry registry) {
|
||||||
|
this.side = registry.registerTexture("stove_side");
|
||||||
|
this.texture2 = registry.registerTexture(this.isLit ? "stove_front_on" : "stove_front_off");
|
||||||
|
this.texture1 = registry.registerTexture(this.isLit ? "stove_top_on" : "stove_top_off");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
@Override
|
||||||
|
public void spawnParticles(World world, int x, int y, int z, Random random) {
|
||||||
|
if (this.isLit) {
|
||||||
|
int var6 = world.getBlockData(x, y, z);
|
||||||
|
float var7 = (float)x + 0.5F + random.nextFloat() * 6.0F / 16.0F;
|
||||||
|
float var8 = (float)y + 1F;
|
||||||
|
float var9 = (float)z + 0.0F;
|
||||||
|
float var10 = 0.52F;
|
||||||
|
float var11 = random.nextFloat() * 0.6F - 0.3F;
|
||||||
|
if (var6 == 4) {
|
||||||
|
world.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0, 0.0, 0.0);
|
||||||
|
world.spawnParticle("flame", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0, 0.0, 0.0);
|
||||||
|
} else if (var6 == 5) {
|
||||||
|
world.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0, 0.0, 0.0);
|
||||||
|
world.spawnParticle("flame", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0, 0.0, 0.0);
|
||||||
|
} else if (var6 == 2) {
|
||||||
|
world.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0, 0.0, 0.0);
|
||||||
|
world.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0, 0.0, 0.0);
|
||||||
|
} else if (var6 == 3) {
|
||||||
|
world.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0, 0.0, 0.0);
|
||||||
|
world.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0, 0.0, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean onActivated(World world, int x, int y, int z, PlayerEntity player, int i, float f, float g, float h) {
|
||||||
|
if (world.isClient) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
StoveBlockEntity var10 = (StoveBlockEntity)world.getBlockEntity(x, y, z);
|
||||||
|
if (var10 != null) {
|
||||||
|
player.stove_entity(var10);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void method_321(boolean bl, World world, int i, int j, int k) {
|
||||||
|
int var5 = world.getBlockData(i, j, k);
|
||||||
|
BlockEntity var6 = world.getBlockEntity(i, j, k);
|
||||||
|
keepInventory = true;
|
||||||
|
if (bl) {
|
||||||
|
world.method_4719(i, j, k,ModBlocks.LIT_STOVE_BLOCK);
|
||||||
|
} else {
|
||||||
|
world.method_4719(i, j, k, ModBlocks.STOVE_BLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
keepInventory = false;
|
||||||
|
world.method_4718(i, j, k, var5, 2);
|
||||||
|
if (var6 != null) {
|
||||||
|
var6.cancelRemoval();
|
||||||
|
world.method_3603(i, j, k, var6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockEntity createBlockEntity(World world, int id) {
|
||||||
|
return new StoveBlockEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBreak(World world, int x, int y, int z, LivingEntity entity, ItemStack item) {
|
||||||
|
int var7 = MathHelper.floor((double)(entity.yaw * 4.0F / 360.0F) + 0.5) & 3;
|
||||||
|
if (var7 == 0) {
|
||||||
|
world.method_4718(x, y, z, 2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var7 == 1) {
|
||||||
|
world.method_4718(x, y, z, 5, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var7 == 2) {
|
||||||
|
world.method_4718(x, y, z, 3, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var7 == 3) {
|
||||||
|
world.method_4718(x, y, z, 4, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.hasCustomName()) {
|
||||||
|
((StoveBlockEntity)world.getBlockEntity(x, y, z)).setCustomName(item.getCustomName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void method_411(World world, int i, int j, int k, Block block, int l) {
|
||||||
|
if (!keepInventory) {
|
||||||
|
StoveBlockEntity var7 = (StoveBlockEntity)world.getBlockEntity(i, j, k);
|
||||||
|
if (var7 != null) {
|
||||||
|
for(int var8 = 0; var8 < var7.getInvSize(); ++var8) {
|
||||||
|
ItemStack var9 = var7.getInvStack(var8);
|
||||||
|
if (var9 != null) {
|
||||||
|
float var10 = this.random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
float var11 = this.random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
float var12 = this.random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
|
||||||
|
while(var9.count > 0) {
|
||||||
|
int var13 = this.random.nextInt(21) + 10;
|
||||||
|
if (var13 > var9.count) {
|
||||||
|
var13 = var9.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
var9.count -= var13;
|
||||||
|
ItemEntity var14 = new ItemEntity(
|
||||||
|
world, (double)((float)i + var10), (double)((float)j + var11), (double)((float)k + var12), new ItemStack(var9.getItem(), var13, var9.getData())
|
||||||
|
);
|
||||||
|
if (var9.hasNbt()) {
|
||||||
|
var14.getItemStack().setNbt((NbtCompound)var9.getNbt().copy());
|
||||||
|
}
|
||||||
|
|
||||||
|
float var15 = 0.05F;
|
||||||
|
var14.velocityX = (double)((float)this.random.nextGaussian() * var15);
|
||||||
|
var14.velocityY = (double)((float)this.random.nextGaussian() * var15 + 0.2F);
|
||||||
|
var14.velocityZ = (double)((float)this.random.nextGaussian() * var15);
|
||||||
|
world.spawnEntity(var14);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
world.method_4725(i, j, k, block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.method_411(world, i, j, k, block, l);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasComparatorOutput() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int method_4793(World world, int i, int j, int k, int l) {
|
||||||
|
return ScreenHandler.calculateComparatorOutput((Inventory)world.getBlockEntity(i, j, k));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
@Override
|
||||||
|
public Item method_407(World world, int i, int j, int k) {
|
||||||
|
return Item.fromBlock(ModBlocks.STOVE_BLOCK);
|
||||||
|
}
|
||||||
|
}
|
327
remappedSrc/xyz/limepot/emb/block/entity/StoveBlockEntity.java
Normal file
327
remappedSrc/xyz/limepot/emb/block/entity/StoveBlockEntity.java
Normal file
|
@ -0,0 +1,327 @@
|
||||||
|
package xyz.limepot.emb.block.entity;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.inventory.SidedInventory;
|
||||||
|
import net.minecraft.item.*;
|
||||||
|
import net.minecraft.nbt.NbtCompound;
|
||||||
|
import net.minecraft.nbt.NbtList;
|
||||||
|
import net.minecraft.recipe.SmeltingRecipeRegistry;
|
||||||
|
import xyz.limepot.emb.block.StoveBlock;
|
||||||
|
|
||||||
|
public class StoveBlockEntity extends BlockEntity implements SidedInventory {
|
||||||
|
private static final int[] inputs = new int[]{0};
|
||||||
|
private static final int[] outputs = new int[]{2, 1};
|
||||||
|
private static final int[] fuelInputs = new int[]{1};
|
||||||
|
private ItemStack[] stacks = new ItemStack[3];
|
||||||
|
public int fuelTime;
|
||||||
|
public int totalFuelTime;
|
||||||
|
public int field_547;
|
||||||
|
private String customName;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInvSize() {
|
||||||
|
return this.stacks.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getInvStack(int slot) {
|
||||||
|
return this.stacks[slot];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack takeInvStack(int slot, int amount) {
|
||||||
|
if (this.stacks[slot] != null) {
|
||||||
|
if (this.stacks[slot].count <= amount) {
|
||||||
|
ItemStack var4 = this.stacks[slot];
|
||||||
|
this.stacks[slot] = null;
|
||||||
|
return var4;
|
||||||
|
} else {
|
||||||
|
ItemStack var3 = this.stacks[slot].split(amount);
|
||||||
|
if (this.stacks[slot].count == 0) {
|
||||||
|
this.stacks[slot] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return var3;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack removeInvStack(int slot) {
|
||||||
|
if (this.stacks[slot] != null) {
|
||||||
|
ItemStack var2 = this.stacks[slot];
|
||||||
|
this.stacks[slot] = null;
|
||||||
|
return var2;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInvStack(int slot, ItemStack stack) {
|
||||||
|
this.stacks[slot] = stack;
|
||||||
|
if (stack != null && stack.count > this.getInvMaxStackAmount()) {
|
||||||
|
stack.count = this.getInvMaxStackAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String method_2385() {
|
||||||
|
return this.method_5339() ? this.customName : "container.stove";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean method_5339() {
|
||||||
|
return this.customName != null && this.customName.length() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomName(String name) {
|
||||||
|
this.customName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromNbt(NbtCompound nbt) {
|
||||||
|
super.fromNbt(nbt);
|
||||||
|
NbtList var2 = nbt.getList("Items", 10);
|
||||||
|
this.stacks = new ItemStack[this.getInvSize()];
|
||||||
|
|
||||||
|
for(int var3 = 0; var3 < var2.size(); ++var3) {
|
||||||
|
NbtCompound var4 = var2.getCompound(var3);
|
||||||
|
byte var5 = var4.getByte("Slot");
|
||||||
|
if (var5 >= 0 && var5 < this.stacks.length) {
|
||||||
|
this.stacks[var5] = ItemStack.fromNbt(var4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fuelTime = nbt.getShort("BurnTime");
|
||||||
|
this.field_547 = nbt.getShort("CookTime");
|
||||||
|
this.totalFuelTime = getBurnTime(this.stacks[1]);
|
||||||
|
if (nbt.contains("CustomName", 8)) {
|
||||||
|
this.customName = nbt.getString("CustomName");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toNbt(NbtCompound nbt) {
|
||||||
|
super.toNbt(nbt);
|
||||||
|
nbt.putShort("BurnTime", (short)this.fuelTime);
|
||||||
|
nbt.putShort("CookTime", (short)this.field_547);
|
||||||
|
NbtList var2 = new NbtList();
|
||||||
|
|
||||||
|
for(int var3 = 0; var3 < this.stacks.length; ++var3) {
|
||||||
|
if (this.stacks[var3] != null) {
|
||||||
|
NbtCompound var4 = new NbtCompound();
|
||||||
|
var4.putByte("Slot", (byte)var3);
|
||||||
|
this.stacks[var3].toNbt(var4);
|
||||||
|
var2.add(var4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nbt.put("Items", var2);
|
||||||
|
if (this.method_5339()) {
|
||||||
|
nbt.putString("CustomName", this.customName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInvMaxStackAmount() {
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public int method_521(int i) {
|
||||||
|
return this.field_547 * i / 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public int method_522(int i) {
|
||||||
|
if (this.totalFuelTime == 0) {
|
||||||
|
this.totalFuelTime = 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.fuelTime * i / this.totalFuelTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFueled() {
|
||||||
|
return this.fuelTime > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void method_545() {
|
||||||
|
boolean var1 = this.fuelTime > 0;
|
||||||
|
boolean var2 = false;
|
||||||
|
if (this.fuelTime > 0) {
|
||||||
|
--this.fuelTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.world.isClient) {
|
||||||
|
if (this.fuelTime != 0 || this.stacks[1] != null && this.stacks[0] != null) {
|
||||||
|
if (this.fuelTime == 0 && this.canAcceptRecipeOutput()) {
|
||||||
|
this.totalFuelTime = this.fuelTime = getBurnTime(this.stacks[1]);
|
||||||
|
if (this.fuelTime > 0) {
|
||||||
|
var2 = true;
|
||||||
|
if (this.stacks[1] != null) {
|
||||||
|
--this.stacks[1].count;
|
||||||
|
if (this.stacks[1].count == 0) {
|
||||||
|
Item var3 = this.stacks[1].getItem().getRecipeRemainder();
|
||||||
|
this.stacks[1] = var3 != null ? new ItemStack(var3) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isFueled() && this.canAcceptRecipeOutput()) {
|
||||||
|
++this.field_547;
|
||||||
|
if (this.field_547 == 200) {
|
||||||
|
this.field_547 = 0;
|
||||||
|
this.craftRecipe();
|
||||||
|
var2 = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.field_547 = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var1 != this.fuelTime > 0) {
|
||||||
|
var2 = true;
|
||||||
|
StoveBlock.method_321(this.fuelTime > 0, this.world, this.x, this.y, this.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var2) {
|
||||||
|
this.markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canAcceptRecipeOutput() {
|
||||||
|
if (this.stacks[0] == null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
ItemStack var1 = SmeltingRecipeRegistry.getInstance().getResult(this.stacks[0]);
|
||||||
|
if (var1 == null) {
|
||||||
|
return false;
|
||||||
|
} else if (this.stacks[2] == null) {
|
||||||
|
return true;
|
||||||
|
} else if (!this.stacks[2].equalsIgnoreNbt(var1)) {
|
||||||
|
return false;
|
||||||
|
} else if (this.stacks[2].count < this.getInvMaxStackAmount() && this.stacks[2].count < this.stacks[2].getMaxCount()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return this.stacks[2].count < var1.getMaxCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void craftRecipe() {
|
||||||
|
if (this.canAcceptRecipeOutput()) {
|
||||||
|
ItemStack var1 = SmeltingRecipeRegistry.getInstance().getResult(this.stacks[0]);
|
||||||
|
if (this.stacks[2] == null) {
|
||||||
|
this.stacks[2] = var1.copy();
|
||||||
|
} else if (this.stacks[2].getItem() == var1.getItem()) {
|
||||||
|
++this.stacks[2].count;
|
||||||
|
}
|
||||||
|
|
||||||
|
--this.stacks[0].count;
|
||||||
|
if (this.stacks[0].count <= 0) {
|
||||||
|
this.stacks[0] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getBurnTime(ItemStack stack) {
|
||||||
|
if (stack == null) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
Item var1 = stack.getItem();
|
||||||
|
if (var1 instanceof BlockItem && Block.getBlockFromItem(var1) != Blocks.AIR) {
|
||||||
|
Block var2 = Block.getBlockFromItem(var1);
|
||||||
|
if (var2 == Blocks.WOODEN_SLAB) {
|
||||||
|
return 150;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var2.getMaterial() == Material.WOOD) {
|
||||||
|
return 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var2 == Blocks.COAL_BLOCK) {
|
||||||
|
return 16000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var1 instanceof ToolItem && ((ToolItem)var1).getMaterialAsString().equals("WOOD")) {
|
||||||
|
return 200;
|
||||||
|
} else if (var1 instanceof SwordItem && ((SwordItem)var1).getToolMaterial().equals("WOOD")) {
|
||||||
|
return 200;
|
||||||
|
} else if (var1 instanceof HoeItem && ((HoeItem)var1).getAsString().equals("WOOD")) {
|
||||||
|
return 200;
|
||||||
|
} else if (var1 == Items.STICK) {
|
||||||
|
return 100;
|
||||||
|
} else if (var1 == Items.COAL) {
|
||||||
|
return 1600;
|
||||||
|
} else if (var1 == Items.LAVA_BUCKET) {
|
||||||
|
return 20000;
|
||||||
|
} else if (var1 == Item.fromBlock(Blocks.SAPLING)) {
|
||||||
|
return 100;
|
||||||
|
} else {
|
||||||
|
return var1 == Items.BLAZE_ROD ? 2400 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFuel(ItemStack stack) {
|
||||||
|
return getBurnTime(stack) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlayerUseInv(PlayerEntity player) {
|
||||||
|
if (this.world.getBlockEntity(this.x, this.y, this.z) != this) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return !(player.squaredDistanceTo((double)this.x + 0.5, (double)this.y + 0.5, (double)this.z + 0.5) > 64.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void method_2390() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void method_2387() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValidInvStack(int slot, ItemStack stack) {
|
||||||
|
if (slot == 2) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return slot == 1 ? isFuel(stack) : true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] method_5355(int i) {
|
||||||
|
if (i == 0) {
|
||||||
|
return outputs;
|
||||||
|
} else {
|
||||||
|
return i == 1 ? inputs : fuelInputs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean method_5353(int i, ItemStack itemStack, int j) {
|
||||||
|
return this.isValidInvStack(i, itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean method_5354(int i, ItemStack itemStack, int j) {
|
||||||
|
return j != 0 || i != 1 || itemStack.getItem() == Items.BUCKET;
|
||||||
|
}
|
||||||
|
}
|
15
remappedSrc/xyz/limepot/emb/client/sound/ModSounds.java
Normal file
15
remappedSrc/xyz/limepot/emb/client/sound/ModSounds.java
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package xyz.limepot.emb.client.sound;
|
||||||
|
|
||||||
|
import net.minecraft.client.sound.Sound;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import xyz.limepot.emb.EMB;
|
||||||
|
|
||||||
|
public class ModSounds {
|
||||||
|
public static final Sound RECORD_FARLANDS = new Sound(new Identifier("emb:farlands"), 1, 0.0, false);
|
||||||
|
public static final Sound RECORD_MODULO = new Sound(new Identifier("emb:modulo"), 1, 0.0, false);
|
||||||
|
|
||||||
|
|
||||||
|
public static void registerModSounds() {
|
||||||
|
EMB.LOGGER.debug("Registering Sounds...");
|
||||||
|
}
|
||||||
|
}
|
39
remappedSrc/xyz/limepot/emb/config/ModConfigProvider.java
Normal file
39
remappedSrc/xyz/limepot/emb/config/ModConfigProvider.java
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
package xyz.limepot.emb.config;
|
||||||
|
|
||||||
|
|
||||||
|
import net.minecraft.util.Pair;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ModConfigProvider implements SimpleConfig.DefaultConfig {
|
||||||
|
|
||||||
|
/*
|
||||||
|
private String configPreLine1 = "#### Even More Bountiful Configs";
|
||||||
|
private String configPreLine2 = "#### ";
|
||||||
|
private String configPreLine3 = "#### Please note this mod is EXTREMELEY expiremental and early in development";
|
||||||
|
private String configPreLine4 = "#### Here be dragons.";
|
||||||
|
private String configPreLine5 = "#### ";
|
||||||
|
private String configPreLine6 = " ";
|
||||||
|
private String configPreLine7 = "## Experimental Options! ";*/
|
||||||
|
|
||||||
|
private String configContents = "";
|
||||||
|
|
||||||
|
public List<Pair> getConfigsList() {
|
||||||
|
return configsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final List<Pair> configsList = new ArrayList<>();
|
||||||
|
|
||||||
|
public void addKeyValuePair(Pair keyValuePair, String comment) {
|
||||||
|
configsList.add(keyValuePair);
|
||||||
|
configContents += keyValuePair.getLeft() + "=" + keyValuePair.getRight() + " #"
|
||||||
|
+ comment + " | default: " + keyValuePair.getRight() + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
//"some.key=value"
|
||||||
|
public String get(String namespace) {
|
||||||
|
return configContents;
|
||||||
|
}
|
||||||
|
}
|
46
remappedSrc/xyz/limepot/emb/config/ModConfigs.java
Normal file
46
remappedSrc/xyz/limepot/emb/config/ModConfigs.java
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
package xyz.limepot.emb.config;
|
||||||
|
|
||||||
|
import net.minecraft.util.Pair;
|
||||||
|
import xyz.limepot.emb.EMB;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class ModConfigs {
|
||||||
|
public static SimpleConfig CONFIG;
|
||||||
|
private static ModConfigProvider configs;
|
||||||
|
public static boolean TUTORIAL_BUTTON_TOGGLE;
|
||||||
|
public static boolean CONFIG_BUTTON_TOGGLE;
|
||||||
|
public static boolean ENABLE_ACHIEVEMENTS;
|
||||||
|
public static int CONFIG_VERSION;
|
||||||
|
|
||||||
|
public static void registerConfigs() {
|
||||||
|
configs = new ModConfigProvider();
|
||||||
|
createConfigs();
|
||||||
|
|
||||||
|
CONFIG = SimpleConfig.of(EMB.MOD_ID).provider(configs).request();
|
||||||
|
|
||||||
|
assignConfigs();
|
||||||
|
if(CONFIG_VERSION == 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
CONFIG.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createConfigs() {
|
||||||
|
configs.addKeyValuePair(new Pair("config.version", 1), "DO NOT EDIT! If this value is anything other than default the mod will delete it.");
|
||||||
|
configs.addKeyValuePair(new Pair("tutorial.button.toggle", false), "True Or False - True being enable the feature, False being disable.");
|
||||||
|
configs.addKeyValuePair(new Pair("config.button.toggle", false), "True Or False - True being enable the feature, False being disable.");
|
||||||
|
configs.addKeyValuePair(new Pair("enable.achievements", false), "True Or False - True being enable the feature, False being disable.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void assignConfigs() {
|
||||||
|
CONFIG_VERSION = CONFIG.getOrDefault("config.version", 1);
|
||||||
|
TUTORIAL_BUTTON_TOGGLE = CONFIG.getOrDefault("tutorial.button.toggle", false);
|
||||||
|
CONFIG_BUTTON_TOGGLE = CONFIG.getOrDefault("config.button.toggle", false);
|
||||||
|
ENABLE_ACHIEVEMENTS = CONFIG.getOrDefault("enable.achievements", false);
|
||||||
|
|
||||||
|
System.out.println("All " + configs.getConfigsList().size() + " have been set properly");
|
||||||
|
}
|
||||||
|
}
|
257
remappedSrc/xyz/limepot/emb/config/SimpleConfig.java
Normal file
257
remappedSrc/xyz/limepot/emb/config/SimpleConfig.java
Normal file
|
@ -0,0 +1,257 @@
|
||||||
|
package xyz.limepot.emb.config;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 magistermaks
|
||||||
|
* Slightly modified by Kaupenjoe 2021
|
||||||
|
* Vaguely modified by LimePotato 2023
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class SimpleConfig {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger("SimpleConfig");
|
||||||
|
private final HashMap<String, String> config = new HashMap<>();
|
||||||
|
private final ConfigRequest request;
|
||||||
|
private static boolean broken = false;
|
||||||
|
|
||||||
|
public interface DefaultConfig {
|
||||||
|
String get( String namespace );
|
||||||
|
|
||||||
|
static String empty( String namespace ) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ConfigRequest {
|
||||||
|
|
||||||
|
private final File file;
|
||||||
|
private final String filename;
|
||||||
|
private DefaultConfig provider;
|
||||||
|
|
||||||
|
private ConfigRequest(File file, String filename ) {
|
||||||
|
this.file = file;
|
||||||
|
this.filename = filename;
|
||||||
|
this.provider = DefaultConfig::empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the default config provider, used to generate the
|
||||||
|
* config if it's missing.
|
||||||
|
*
|
||||||
|
* @param provider default config provider
|
||||||
|
* @return current config request object
|
||||||
|
* @see DefaultConfig
|
||||||
|
*/
|
||||||
|
public ConfigRequest provider( DefaultConfig provider ) {
|
||||||
|
this.provider = provider;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the config from the filesystem.
|
||||||
|
*
|
||||||
|
* @return config object
|
||||||
|
* @see SimpleConfig
|
||||||
|
*/
|
||||||
|
public SimpleConfig request() {
|
||||||
|
return new SimpleConfig( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
String getConfig() {
|
||||||
|
return provider.get( filename ) + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new config request object, ideally `namespace`
|
||||||
|
* should be the name of the mod id of the requesting mod
|
||||||
|
*
|
||||||
|
* @param filename - name of the config file
|
||||||
|
* @return new config request object
|
||||||
|
*/
|
||||||
|
public static ConfigRequest of( String filename ) {
|
||||||
|
Path path = FabricLoader.getInstance().getConfigDir();
|
||||||
|
//Changed from .properties to .cfg by LimePotato
|
||||||
|
return new ConfigRequest( path.resolve( filename + ".cfg" ).toFile(), filename );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createConfig() throws IOException {
|
||||||
|
|
||||||
|
// try creating missing files
|
||||||
|
request.file.getParentFile().mkdirs();
|
||||||
|
Files.createFile( request.file.toPath() );
|
||||||
|
|
||||||
|
// write default config data
|
||||||
|
PrintWriter writer = new PrintWriter(request.file, "UTF-8");
|
||||||
|
writer.write( request.getConfig() );
|
||||||
|
writer.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadConfig() throws IOException {
|
||||||
|
Scanner reader = new Scanner( request.file );
|
||||||
|
for( int line = 1; reader.hasNextLine(); line ++ ) {
|
||||||
|
parseConfigEntry( reader.nextLine(), line );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modification by Kaupenjoe
|
||||||
|
private void parseConfigEntry( String entry, int line ) {
|
||||||
|
if( !entry.isEmpty() && !entry.startsWith( "#" ) ) {
|
||||||
|
String[] parts = entry.split("=", 2);
|
||||||
|
if( parts.length == 2 ) {
|
||||||
|
// Recognizes comments after a value
|
||||||
|
String temp = parts[1].split(" #")[0];
|
||||||
|
config.put( parts[0], temp );
|
||||||
|
}else{
|
||||||
|
throw new RuntimeException("Syntax error in config file on line " + line + "!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private SimpleConfig(ConfigRequest request ) {
|
||||||
|
this.request = request;
|
||||||
|
String identifier = "Config '" + request.filename + "'";
|
||||||
|
|
||||||
|
if( !request.file.exists() ) {
|
||||||
|
LOGGER.info( identifier + " is missing, generating default one..." );
|
||||||
|
|
||||||
|
try {
|
||||||
|
createConfig();
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOGGER.error( identifier + " failed to generate!" );
|
||||||
|
LOGGER.trace( e );
|
||||||
|
broken = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !broken ) {
|
||||||
|
try {
|
||||||
|
loadConfig();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.error( identifier + " failed to load!" );
|
||||||
|
LOGGER.trace( e );
|
||||||
|
broken = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queries a value from config, returns `null` if the
|
||||||
|
* key does not exist.
|
||||||
|
*
|
||||||
|
* @return value corresponding to the given key
|
||||||
|
* @see SimpleConfig#getOrDefault
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public String get( String key ) {
|
||||||
|
return config.get( key );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns string value from config corresponding to the given
|
||||||
|
* key, or the default string if the key is missing.
|
||||||
|
*
|
||||||
|
* @return value corresponding to the given key, or the default value
|
||||||
|
*/
|
||||||
|
public String getOrDefault( String key, String def ) {
|
||||||
|
String val = get(key);
|
||||||
|
return val == null ? def : val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns integer value from config corresponding to the given
|
||||||
|
* key, or the default integer if the key is missing or invalid.
|
||||||
|
*
|
||||||
|
* @return value corresponding to the given key, or the default value
|
||||||
|
*/
|
||||||
|
public int getOrDefault( String key, int def ) {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt( get(key) );
|
||||||
|
} catch (Exception e) {
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns boolean value from config corresponding to the given
|
||||||
|
* key, or the default boolean if the key is missing.
|
||||||
|
*
|
||||||
|
* @return value corresponding to the given key, or the default value
|
||||||
|
*/
|
||||||
|
public boolean getOrDefault( String key, boolean def ) {
|
||||||
|
String val = get(key);
|
||||||
|
if( val != null ) {
|
||||||
|
return val.equalsIgnoreCase("true");
|
||||||
|
}
|
||||||
|
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns double value from config corresponding to the given
|
||||||
|
* key, or the default string if the key is missing or invalid.
|
||||||
|
*
|
||||||
|
* @return value corresponding to the given key, or the default value
|
||||||
|
*/
|
||||||
|
public double getOrDefault( String key, double def ) {
|
||||||
|
try {
|
||||||
|
return Double.parseDouble( get(key) );
|
||||||
|
} catch (Exception e) {
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If any error occurred during loading or reading from the config
|
||||||
|
* a 'broken' flag is set, indicating that the config's state
|
||||||
|
* is undefined and should be discarded using `delete()`
|
||||||
|
*
|
||||||
|
* @return the 'broken' flag of the configuration
|
||||||
|
*/
|
||||||
|
public boolean isBroken() {
|
||||||
|
return broken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deletes the config file from the filesystem
|
||||||
|
*
|
||||||
|
* @return true if the operation was successful
|
||||||
|
*/
|
||||||
|
public boolean delete() {
|
||||||
|
LOGGER.warn( "Config '" + request.filename + "' was removed from existence! Restart the game to regenerate it." );
|
||||||
|
return request.file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
9
remappedSrc/xyz/limepot/emb/entity/ModStatusEffect.java
Normal file
9
remappedSrc/xyz/limepot/emb/entity/ModStatusEffect.java
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package xyz.limepot.emb.entity;
|
||||||
|
|
||||||
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
|
|
||||||
|
public class ModStatusEffect extends StatusEffect {
|
||||||
|
protected ModStatusEffect(int i, boolean bl, int j) {
|
||||||
|
super(i, bl, j);
|
||||||
|
}
|
||||||
|
}
|
22
remappedSrc/xyz/limepot/emb/entity/ModStatusEffects.java
Normal file
22
remappedSrc/xyz/limepot/emb/entity/ModStatusEffects.java
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package xyz.limepot.emb.entity;
|
||||||
|
|
||||||
|
import net.legacyfabric.fabric.api.registry.v1.RegistryHelper;
|
||||||
|
import net.legacyfabric.fabric.api.registry.v1.StatusEffectIds;
|
||||||
|
import net.legacyfabric.fabric.api.util.Identifier;
|
||||||
|
import net.legacyfabric.fabric.impl.registry.RegistryHelperImpl;
|
||||||
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
|
import xyz.limepot.emb.EMB;
|
||||||
|
|
||||||
|
import static xyz.limepot.emb.EMB.MOD_ID;
|
||||||
|
|
||||||
|
public class ModStatusEffects {
|
||||||
|
|
||||||
|
public static final StatusEffect CUM_EFFECT = registerStatusEffect((id) -> new ModStatusEffect(id, true, 5578058), new Identifier(MOD_ID, "potion.cum"));
|
||||||
|
|
||||||
|
public static StatusEffect registerStatusEffect(RegistryHelper.EntryCreator<StatusEffect> statusEffect,/*String name*/ Identifier id) {
|
||||||
|
return RegistryHelperImpl.registerStatusEffect(statusEffect, /*new Identifier(MOD_ID, name)*/ id);
|
||||||
|
}
|
||||||
|
public static void registerModStatusEffects() { EMB.LOGGER.debug("Registering Status Effects....");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package xyz.limepot.emb.entity.player;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.util.Session;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import xyz.limepot.emb.block.entity.StoveBlockEntity;
|
||||||
|
import xyz.limepot.emb.gui.screen.StoveScreen;
|
||||||
|
|
||||||
|
public class ClientPlayerEntity extends net.minecraft.entity.player.ClientPlayerEntity {
|
||||||
|
protected static MinecraftClient client;
|
||||||
|
public ClientPlayerEntity(MinecraftClient minecraftClient, World world, Session session, int i) {
|
||||||
|
super(minecraftClient, world, session, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stove_entity(StoveBlockEntity stoveBlockEntity) {
|
||||||
|
ClientPlayerEntity.client.setScreen(new StoveScreen(this.inventory, stoveBlockEntity));
|
||||||
|
}
|
||||||
|
}
|
35
remappedSrc/xyz/limepot/emb/entity/player/PlayerEntity.java
Normal file
35
remappedSrc/xyz/limepot/emb/entity/player/PlayerEntity.java
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package xyz.limepot.emb.entity.player;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import net.minecraft.block.entity.FurnaceBlockEntity;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import xyz.limepot.emb.block.entity.StoveBlockEntity;
|
||||||
|
import xyz.limepot.emb.gui.screen.StoveScreen;
|
||||||
|
|
||||||
|
public class PlayerEntity extends net.minecraft.entity.player.PlayerEntity {
|
||||||
|
public PlayerEntity(World world, GameProfile gameProfile) {
|
||||||
|
super(world, gameProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stove_entity(StoveBlockEntity stoveBlockEntity){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(Text text) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseCommand(int permissionLevel, String commandLiteral) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockPos method_4086() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
54
remappedSrc/xyz/limepot/emb/gui/screen/EMBConfScreen.java
Normal file
54
remappedSrc/xyz/limepot/emb/gui/screen/EMBConfScreen.java
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
package xyz.limepot.emb.gui.screen;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.client.gui.screen.*;
|
||||||
|
import net.minecraft.client.gui.widget.*;
|
||||||
|
import net.minecraft.client.option.GameOptions;
|
||||||
|
import net.minecraft.client.resource.language.I18n;
|
||||||
|
import xyz.limepot.emb.config.ModConfigs;
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public class EMBConfScreen extends Screen implements IdentifiableBooleanConsumer {
|
||||||
|
private final Screen parent;
|
||||||
|
private final GameOptions options;
|
||||||
|
protected String title = "EMB Configs";
|
||||||
|
|
||||||
|
public EMBConfScreen(Screen screen, GameOptions gameOptions) {
|
||||||
|
this.parent = screen;
|
||||||
|
this.options = gameOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
this.title = I18n.translate("options.embConfTitle");
|
||||||
|
|
||||||
|
if(ModConfigs.TUTORIAL_BUTTON_TOGGLE) {
|
||||||
|
this.buttons.add(new ButtonWidget(900, this.width / 2 - 155, this.height / 6 + 72 - 6, 150, 20, I18n.translate("emb.options.toggle.tutorial.enable")));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.buttons.add(new ButtonWidget(901, this.width / 2 - 155, this.height / 6 + 72 - 6, 150, 20, I18n.translate("emb.options.toggle.tutorial.disable")));
|
||||||
|
}
|
||||||
|
this.buttons.add(new ButtonWidget(200, this.width / 2 - 100, this.height / 6 + 168, I18n.translate("gui.done")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void buttonClicked(ButtonWidget button) {
|
||||||
|
if (button.active) {
|
||||||
|
if (button.id == 900) {
|
||||||
|
ModConfigs.TUTORIAL_BUTTON_TOGGLE = false;
|
||||||
|
}
|
||||||
|
if (button.id == 901) {
|
||||||
|
ModConfigs.TUTORIAL_BUTTON_TOGGLE = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(int mouseX, int mouseY, float tickDelta) {
|
||||||
|
this.renderBackground();
|
||||||
|
this.drawCenteredString(this.textRenderer, this.title, this.width / 2, 15, 16777215);
|
||||||
|
super.render(mouseX, mouseY, tickDelta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
40
remappedSrc/xyz/limepot/emb/gui/screen/StoveScreen.java
Normal file
40
remappedSrc/xyz/limepot/emb/gui/screen/StoveScreen.java
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
package xyz.limepot.emb.gui.screen;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||||
|
import net.minecraft.client.resource.language.I18n;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import xyz.limepot.emb.block.entity.StoveBlockEntity;
|
||||||
|
|
||||||
|
public class StoveScreen extends HandledScreen {
|
||||||
|
private static final Identifier TEXTURE = new Identifier("textures/gui/container/furnace.png");
|
||||||
|
private StoveBlockEntity field_1402;
|
||||||
|
|
||||||
|
public StoveScreen(PlayerInventory playerInventory, StoveBlockEntity stoveBlockEntity) {
|
||||||
|
super(new StoveScreenHandler(playerInventory, stoveBlockEntity));
|
||||||
|
this.field_1402 = stoveBlockEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawForeground(int mouseX, int mouseY) {
|
||||||
|
String var3 = this.field_1402.method_5339() ? this.field_1402.method_2385() : I18n.translate(this.field_1402.method_2385());
|
||||||
|
this.textRenderer.draw(var3, this.backgroundWidth / 2 - this.textRenderer.getStringWidth(var3) / 2, 6, 4210752);
|
||||||
|
this.textRenderer.draw(I18n.translate("container.inventory"), 8, this.backgroundHeight - 96 + 2, 4210752);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawBackground(float delta, int mouseX, int mouseY) {
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
this.client.getTextureManager().bindTexture(TEXTURE);
|
||||||
|
int var4 = (this.width - this.backgroundWidth) / 2;
|
||||||
|
int var5 = (this.height - this.backgroundHeight) / 2;
|
||||||
|
this.drawTexture(var4, var5, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||||
|
if (this.field_1402.isFueled()) {
|
||||||
|
int var6 = this.field_1402.method_522(13);
|
||||||
|
this.drawTexture(var4 + 56, var5 + 36 + 12 - var6, 176, 12 - var6, 14, var6 + 1);
|
||||||
|
var6 = this.field_1402.method_521(24);
|
||||||
|
this.drawTexture(var4 + 79, var5 + 34, 176, 14, var6 + 1, 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
139
remappedSrc/xyz/limepot/emb/gui/screen/StoveScreenHandler.java
Normal file
139
remappedSrc/xyz/limepot/emb/gui/screen/StoveScreenHandler.java
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
package xyz.limepot.emb.gui.screen;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.inventory.slot.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.recipe.SmeltingRecipeRegistry;
|
||||||
|
import net.minecraft.screen.ScreenHandler;
|
||||||
|
import net.minecraft.screen.ScreenHandlerListener;
|
||||||
|
import xyz.limepot.emb.block.entity.StoveBlockEntity;
|
||||||
|
import xyz.limepot.emb.inventory.StoveOutputSlot;
|
||||||
|
|
||||||
|
public class StoveScreenHandler extends ScreenHandler {
|
||||||
|
private StoveBlockEntity instance;
|
||||||
|
private int cookTime;
|
||||||
|
private int field_4124;
|
||||||
|
private int field_4125;
|
||||||
|
|
||||||
|
public StoveScreenHandler(PlayerInventory playerInventory, StoveBlockEntity stoveBlockEntity) {
|
||||||
|
this.instance = stoveBlockEntity;
|
||||||
|
this.addSlot(new Slot(stoveBlockEntity, 0, 56, 17));
|
||||||
|
this.addSlot(new Slot(stoveBlockEntity, 1, 56, 53));
|
||||||
|
this.addSlot(new StoveOutputSlot(playerInventory.player, stoveBlockEntity, 2, 116, 35));
|
||||||
|
|
||||||
|
for(int var3 = 0; var3 < 3; ++var3) {
|
||||||
|
for(int var4 = 0; var4 < 9; ++var4) {
|
||||||
|
this.addSlot(new Slot(playerInventory, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int var5 = 0; var5 < 9; ++var5) {
|
||||||
|
this.addSlot(new Slot(playerInventory, var5, 8 + var5 * 18, 142));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addListener(ScreenHandlerListener listener) {
|
||||||
|
super.addListener(listener);
|
||||||
|
listener.onScreenHandlerPropertyUpdate(this, 0, this.instance.field_547);
|
||||||
|
listener.onScreenHandlerPropertyUpdate(this, 1, this.instance.fuelTime);
|
||||||
|
listener.onScreenHandlerPropertyUpdate(this, 2, this.instance.totalFuelTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendContentUpdates() {
|
||||||
|
super.sendContentUpdates();
|
||||||
|
|
||||||
|
for(int var1 = 0; var1 < this.listeners.size(); ++var1) {
|
||||||
|
ScreenHandlerListener var2 = (ScreenHandlerListener)this.listeners.get(var1);
|
||||||
|
if (this.cookTime != this.instance.field_547) {
|
||||||
|
var2.onScreenHandlerPropertyUpdate(this, 0, this.instance.field_547);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.field_4124 != this.instance.fuelTime) {
|
||||||
|
var2.onScreenHandlerPropertyUpdate(this, 1, this.instance.fuelTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.field_4125 != this.instance.totalFuelTime) {
|
||||||
|
var2.onScreenHandlerPropertyUpdate(this, 2, this.instance.totalFuelTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.cookTime = this.instance.field_547;
|
||||||
|
this.field_4124 = this.instance.fuelTime;
|
||||||
|
this.field_4125 = this.instance.totalFuelTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
@Override
|
||||||
|
public void setProperty(int id, int value) {
|
||||||
|
if (id == 0) {
|
||||||
|
this.instance.field_547 = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id == 1) {
|
||||||
|
this.instance.fuelTime = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id == 2) {
|
||||||
|
this.instance.totalFuelTime = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUse(PlayerEntity player) {
|
||||||
|
return this.instance.canPlayerUseInv(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack transferSlot(PlayerEntity player, int invSlot) {
|
||||||
|
ItemStack var3 = null;
|
||||||
|
Slot var4 = (Slot)this.slots.get(invSlot);
|
||||||
|
if (var4 != null && var4.hasStack()) {
|
||||||
|
ItemStack var5 = var4.getStack();
|
||||||
|
var3 = var5.copy();
|
||||||
|
if (invSlot == 2) {
|
||||||
|
if (!this.insertItem(var5, 3, 39, true)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var4.onStackChanged(var5, var3);
|
||||||
|
} else if (invSlot != 1 && invSlot != 0) {
|
||||||
|
if (SmeltingRecipeRegistry.getInstance().getResult(var5) != null) {
|
||||||
|
if (!this.insertItem(var5, 0, 1, false)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else if (StoveBlockEntity.isFuel(var5)) {
|
||||||
|
if (!this.insertItem(var5, 1, 2, false)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else if (invSlot >= 3 && invSlot < 30) {
|
||||||
|
if (!this.insertItem(var5, 30, 39, false)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else if (invSlot >= 30 && invSlot < 39 && !this.insertItem(var5, 3, 30, false)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else if (!this.insertItem(var5, 3, 39, false)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var5.count == 0) {
|
||||||
|
var4.setStack(null);
|
||||||
|
} else {
|
||||||
|
var4.markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var5.count == var3.count) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var4.onTakeItem(player, var5);
|
||||||
|
}
|
||||||
|
|
||||||
|
return var3;
|
||||||
|
}
|
||||||
|
}
|
81
remappedSrc/xyz/limepot/emb/inventory/StoveOutputSlot.java
Normal file
81
remappedSrc/xyz/limepot/emb/inventory/StoveOutputSlot.java
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
package xyz.limepot.emb.inventory;
|
||||||
|
|
||||||
|
import net.minecraft.advancement.AchievementsAndCriterions;
|
||||||
|
import net.minecraft.entity.ExperienceOrbEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.inventory.Inventory;
|
||||||
|
import net.minecraft.inventory.slot.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.recipe.SmeltingRecipeRegistry;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
|
public class StoveOutputSlot extends Slot {
|
||||||
|
private PlayerEntity player;
|
||||||
|
private int amount;
|
||||||
|
|
||||||
|
public StoveOutputSlot(PlayerEntity playerEntity, Inventory inventory, int i, int j, int k) {
|
||||||
|
super(inventory, i, j, k);
|
||||||
|
this.player = playerEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInsert(ItemStack stack) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack takeStack(int amount) {
|
||||||
|
if (this.hasStack()) {
|
||||||
|
this.amount += Math.min(amount, this.getStack().count);
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.takeStack(amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTakeItem(PlayerEntity player, ItemStack stack) {
|
||||||
|
this.onCrafted(stack);
|
||||||
|
super.onTakeItem(player, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCrafted(ItemStack stack, int amount) {
|
||||||
|
this.amount += amount;
|
||||||
|
this.onCrafted(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCrafted(ItemStack stack) {
|
||||||
|
stack.onCraft(this.player.world, this.player, this.amount);
|
||||||
|
if (!this.player.world.isClient) {
|
||||||
|
int var2 = this.amount;
|
||||||
|
float var3 = SmeltingRecipeRegistry.getInstance().getXp(stack);
|
||||||
|
if (var3 == 0.0F) {
|
||||||
|
var2 = 0;
|
||||||
|
} else if (var3 < 1.0F) {
|
||||||
|
int var4 = MathHelper.floor((float)var2 * var3);
|
||||||
|
if (var4 < MathHelper.ceil((float)var2 * var3) && (float)Math.random() < (float)var2 * var3 - (float)var4) {
|
||||||
|
++var4;
|
||||||
|
}
|
||||||
|
|
||||||
|
var2 = var4;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(var2 > 0) {
|
||||||
|
int var5 = ExperienceOrbEntity.roundToOrbSize(var2);
|
||||||
|
var2 -= var5;
|
||||||
|
this.player.world.spawnEntity(new ExperienceOrbEntity(this.player.world, this.player.x, this.player.y + 0.5, this.player.z + 0.5, var5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.amount = 0;
|
||||||
|
if (stack.getItem() == Items.IRON_INGOT) {
|
||||||
|
this.player.incrementStat(AchievementsAndCriterions.ACQUIRE_IRON, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stack.getItem() == Items.field_7018) {
|
||||||
|
this.player.incrementStat(AchievementsAndCriterions.COOK_FISH, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
remappedSrc/xyz/limepot/emb/item/ModBlockItems.java
Normal file
4
remappedSrc/xyz/limepot/emb/item/ModBlockItems.java
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
package xyz.limepot.emb.item;
|
||||||
|
|
||||||
|
public class ModBlockItems {
|
||||||
|
}
|
17
remappedSrc/xyz/limepot/emb/item/ModDiscItem.java
Normal file
17
remappedSrc/xyz/limepot/emb/item/ModDiscItem.java
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package xyz.limepot.emb.item;
|
||||||
|
|
||||||
|
import net.minecraft.item.MusicDiscItem;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ModDiscItem extends MusicDiscItem {
|
||||||
|
private static final Map records = new HashMap();
|
||||||
|
public final String recordType;
|
||||||
|
public ModDiscItem(String recordType) {
|
||||||
|
super(recordType);
|
||||||
|
this.recordType = recordType;
|
||||||
|
records.put(recordType, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
58
remappedSrc/xyz/limepot/emb/item/ModItems.java
Normal file
58
remappedSrc/xyz/limepot/emb/item/ModItems.java
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
package xyz.limepot.emb.item;
|
||||||
|
|
||||||
|
import com.jcraft.jorbis.Block;
|
||||||
|
import net.legacyfabric.fabric.api.util.Identifier;
|
||||||
|
import net.legacyfabric.fabric.impl.registry.RegistryHelperImpl;
|
||||||
|
import net.minecraft.item.*;
|
||||||
|
import net.minecraft.item.itemgroup.ItemGroup;
|
||||||
|
import xyz.limepot.emb.EMB;
|
||||||
|
import xyz.limepot.emb.block.ModBlocks;
|
||||||
|
|
||||||
|
import static xyz.limepot.emb.EMB.MOD_ID;
|
||||||
|
|
||||||
|
|
||||||
|
public class ModItems {
|
||||||
|
//Register Items
|
||||||
|
//Vivian
|
||||||
|
public static final Item COOKED_EGG = registerItem(new FoodItem(6, 0.6F, false).setItemGroup(ItemGroup.FOOD), "cooked_egg");
|
||||||
|
|
||||||
|
//Coins //Gold, Iron, Emerald?
|
||||||
|
public static final Item GOLD_COIN = registerItem(new Item().setItemGroup(ItemGroup.MISC), "gold_coin");
|
||||||
|
public static final Item IRON_COIN = registerItem(new Item().setItemGroup(ItemGroup.MISC), "iron_coin");
|
||||||
|
public static final Item IRON_NUGGET = registerItem(new Item().setItemGroup(ItemGroup.MATERIALS), "iron_nugget");
|
||||||
|
|
||||||
|
//Music Discs
|
||||||
|
public static final Item FARLANDS_RECORD = registerItem(new ModDiscItem("farlands"), "record_farlands");
|
||||||
|
public static final Item MODULO_RECORD = registerItem(new ModDiscItem("modulo"), "record_modulo");
|
||||||
|
public static final Item NO_NAME_RECORD = registerItem(new ModDiscItem("no_name"), "record_no_name");
|
||||||
|
public static final Item SUNRISE_RECORD = registerItem(new ModDiscItem("sunrise"), "record_sunrise");
|
||||||
|
|
||||||
|
//Other
|
||||||
|
public static final Item GOLD_KEY = registerItem(new Item().setItemGroup(ItemGroup.TOOLS), "gold_key");
|
||||||
|
public static final Item IRON_KEY = registerItem(new Item().setItemGroup(ItemGroup.TOOLS), "iron_key");
|
||||||
|
public static final Item WOOD_KEY = registerItem(new Item().setItemGroup(ItemGroup.TOOLS), "wood_key");
|
||||||
|
|
||||||
|
public static final Item CHAIN = registerItem(new Item().setItemGroup(ItemGroup.DECORATIONS), "chain");
|
||||||
|
public static final Item ROPE = registerItem(new BlockItem(ModBlocks.ROPE).setItemGroup(ItemGroup.DECORATIONS), "rope");
|
||||||
|
|
||||||
|
//Block Items
|
||||||
|
public static final Item IRON_BUTTON_ITEM = registerItem(new BlockItem(ModBlocks.IRON_BUTTON).setItemGroup(ItemGroup.DECORATIONS), "iron_button");
|
||||||
|
public static final Item CYAN_ROSE_ITEM = registerItem(new BlockItem(ModBlocks.CYAN_ROSE).setItemGroup(ItemGroup.DECORATIONS), "cyan_rose");
|
||||||
|
public static final Item STOVE_BLOCK_ITEM = registerItem(new BlockItem(ModBlocks.STOVE_BLOCK).setItemGroup(ItemGroup.DECORATIONS), "stove_block");
|
||||||
|
public static final Item PALM_LOG_ITEM = registerItem(new BlockItem(ModBlocks.PALM_LOG_BLOCK).setItemGroup(ItemGroup.DECORATIONS), "palm_log");
|
||||||
|
|
||||||
|
|
||||||
|
//Potions/Medicine
|
||||||
|
/*this actually registers an entire set of potion items, potion item/potion bottle*/
|
||||||
|
//public static final Item ANTIDOTE_ITEM = registerItem(new PotionItem().setItemGroup(ItemGroup.BREWING), "antidote");
|
||||||
|
|
||||||
|
//Register Items
|
||||||
|
public static Item registerItem(Item item, String name) {
|
||||||
|
return RegistryHelperImpl.registerItem(item.getFromId(name), new Identifier(MOD_ID, name));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Method to call in main class
|
||||||
|
public static void registerModItems() { EMB.LOGGER.debug("Registering Items....");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
29
remappedSrc/xyz/limepot/emb/mixin/SettingScreenMixin.java
Normal file
29
remappedSrc/xyz/limepot/emb/mixin/SettingScreenMixin.java
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package xyz.limepot.emb.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.gui.screen.SettingsScreen;
|
||||||
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
|
import net.minecraft.client.resource.language.I18n;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import xyz.limepot.emb.config.ModConfigs;
|
||||||
|
import xyz.limepot.emb.gui.screen.EMBConfScreen;
|
||||||
|
import xyz.limepot.emb.gui.screen.StoveScreenHandler;
|
||||||
|
|
||||||
|
@Mixin(SettingsScreen.class)
|
||||||
|
public class SettingScreenMixin extends Screen {
|
||||||
|
@Inject(at = @At("RETURN"), method = "init")
|
||||||
|
private void addCustomButton(CallbackInfo ci) {
|
||||||
|
if(ModConfigs.CONFIG_BUTTON_TOGGLE) {
|
||||||
|
this.buttons.add(new ButtonWidget(13, this.width / 2 - 155, this.height / 6 + 48 - 6, 150, 20, I18n.translate("menu.embOptions", new Object[0])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(at = @At("RETURN"), method = "buttonClicked")
|
||||||
|
private void CustomButtonClicked(ButtonWidget par1, CallbackInfo ci) {
|
||||||
|
if (par1.id == 13) this.client.setScreen(new EMBConfScreen(this, this.client.options));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
18
remappedSrc/xyz/limepot/emb/mixin/TitleMixin.java
Normal file
18
remappedSrc/xyz/limepot/emb/mixin/TitleMixin.java
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package xyz.limepot.emb.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||||
|
|
||||||
|
@Mixin(MinecraftClient.class)
|
||||||
|
public class TitleMixin {
|
||||||
|
@ModifyArg(method = "initializeGame", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V"))
|
||||||
|
private String addEMBBranding(String text) {
|
||||||
|
if (text.contains("Minecraft")) {
|
||||||
|
text = "EMB 1.7.11.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
43
remappedSrc/xyz/limepot/emb/mixin/TitleScreenMixin.java
Normal file
43
remappedSrc/xyz/limepot/emb/mixin/TitleScreenMixin.java
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package xyz.limepot.emb.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.gui.screen.SettingsScreen;
|
||||||
|
import net.minecraft.client.gui.screen.TitleScreen;
|
||||||
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
|
import net.minecraft.client.resource.language.I18n;
|
||||||
|
import net.minecraft.world.DemoServerWorld;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import static xyz.limepot.emb.EMB.MOD_ID;
|
||||||
|
import static xyz.limepot.emb.EMB.MOD_VER;
|
||||||
|
import static xyz.limepot.emb.config.ModConfigs.*;
|
||||||
|
|
||||||
|
@Mixin(TitleScreen.class)
|
||||||
|
public class TitleScreenMixin extends Screen {
|
||||||
|
|
||||||
|
//Tutorial Button, Temprorarily disabled in config until I can figure out how to package the world with the mod and hijack the world loading process, oh and make a nice gui screen maybe?
|
||||||
|
@Inject(at = @At("RETURN"), method = "initWidgetsNormal")
|
||||||
|
private void addCustomButton(int spacingY, int par2, CallbackInfo ci) {
|
||||||
|
if(TUTORIAL_BUTTON_TOGGLE) {
|
||||||
|
this.buttons.add(new ButtonWidget(13, this.width / 2 + 105, 108, 50, 20, I18n.translate("menu.tutorial", new Object[0])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(at = @At("RETURN"), method = "buttonClicked")
|
||||||
|
private void CustomButtonClicked(ButtonWidget par1, CallbackInfo ci) {
|
||||||
|
if (par1.id == 13) this.client.startIntegratedServer("Demo_World", "Demo_World", DemoServerWorld.INFO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/TitleScreen;drawWithShadow(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;III)V"))
|
||||||
|
private String addEMBBranding(String text) {
|
||||||
|
if (text.contains("Minecraft")) {
|
||||||
|
text += "/" + MOD_ID + MOD_VER;
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
33
remappedSrc/xyz/limepot/emb/recipe/ModCraftingRecipes.java
Normal file
33
remappedSrc/xyz/limepot/emb/recipe/ModCraftingRecipes.java
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
package xyz.limepot.emb.recipe;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.recipe.*;
|
||||||
|
import xyz.limepot.emb.block.ModBlocks;
|
||||||
|
import xyz.limepot.emb.item.ModItems;
|
||||||
|
|
||||||
|
public class ModCraftingRecipes {
|
||||||
|
//Call an instance of the RecipeDispatcher
|
||||||
|
public static RecipeDispatcher REGISTRY = RecipeDispatcher.getInstance();
|
||||||
|
|
||||||
|
public static void registerModRecipes(){
|
||||||
|
REGISTRY.registerShapelessRecipe(new ItemStack(Items.DYE, 1, 6), ModBlocks.CYAN_ROSE);
|
||||||
|
REGISTRY.registerShapelessRecipe(new ItemStack(ModItems.IRON_NUGGET, 9), Items.IRON_INGOT);
|
||||||
|
|
||||||
|
REGISTRY.registerShapedRecipe(new ItemStack(ModItems.CHAIN, 6), "# #", "###", "# #", '#', Items.IRON_INGOT);
|
||||||
|
REGISTRY.registerShapedRecipe(new ItemStack(ModItems.ROPE, 6), "# #", "###", "# #", '#', Items.STRING);
|
||||||
|
|
||||||
|
//CHAINMAIL
|
||||||
|
REGISTRY.registerShapedRecipe(new ItemStack(Items.CHAINMAIL_HELMET, 1), "###", "# #", '#', ModItems.CHAIN);
|
||||||
|
REGISTRY.registerShapedRecipe(new ItemStack(Items.CHAINMAIL_CHESTPLATE, 1), "# #", "###", "###", '#', ModItems.CHAIN);
|
||||||
|
REGISTRY.registerShapedRecipe(new ItemStack(Items.CHAINMAIL_LEGGINGS, 1), "###", "# #", "# #", '#', ModItems.CHAIN);
|
||||||
|
REGISTRY.registerShapedRecipe(new ItemStack(Items.CHAINMAIL_BOOTS, 1), " ", "# #", "# #", '#', ModItems.CHAIN);
|
||||||
|
|
||||||
|
//Keys
|
||||||
|
REGISTRY.registerShapedRecipe(new ItemStack(ModItems.IRON_KEY, 1), "#X ", "#X ", "## ", '#', Items.IRON_INGOT, 'X', ModItems.IRON_NUGGET);
|
||||||
|
REGISTRY.registerShapedRecipe(new ItemStack(ModItems.GOLD_KEY, 1), "#X ", "#X ", "## ", '#', Items.GOLD_INGOT, 'X', Items.GOLD_NUGGET);
|
||||||
|
REGISTRY.registerShapedRecipe(new ItemStack(ModItems.WOOD_KEY, 1), "#X ", "#X ", "## ", '#', Blocks.PLANKS, 'X', Items.STICK);
|
||||||
|
}
|
||||||
|
}
|
22
remappedSrc/xyz/limepot/emb/recipe/ModSemltingRecipes.java
Normal file
22
remappedSrc/xyz/limepot/emb/recipe/ModSemltingRecipes.java
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package xyz.limepot.emb.recipe;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.recipe.SmeltingRecipeRegistry;
|
||||||
|
import xyz.limepot.emb.EMB;
|
||||||
|
import xyz.limepot.emb.item.ModItems;
|
||||||
|
|
||||||
|
public class ModSemltingRecipes {
|
||||||
|
//Call an instance of the SmeltingRecipeRegistry
|
||||||
|
public static SmeltingRecipeRegistry REGISTRY = SmeltingRecipeRegistry.getInstance();
|
||||||
|
|
||||||
|
public static void registerModSmeltingRecipes() {
|
||||||
|
//Register Recipes
|
||||||
|
//REGISTRY.addItem(Items.EGG, new ItemStack(ModItems.COOKED_EGG), 0.35F);
|
||||||
|
REGISTRY.addItem(ModItems.IRON_NUGGET, new ItemStack(ModItems.IRON_COIN), 1F);
|
||||||
|
REGISTRY.addItem(Items.GOLD_NUGGET, new ItemStack(ModItems.GOLD_COIN), 1F);
|
||||||
|
|
||||||
|
//Log
|
||||||
|
EMB.LOGGER.debug("Registering Items....");
|
||||||
|
}
|
||||||
|
}
|
71
remappedSrc/xyz/limepot/emb/recipe/StoveRecipeRegistry.java
Normal file
71
remappedSrc/xyz/limepot/emb/recipe/StoveRecipeRegistry.java
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
package xyz.limepot.emb.recipe;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import xyz.limepot.emb.item.ModItems;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class StoveRecipeRegistry {
|
||||||
|
private static final StoveRecipeRegistry INSTANCE = new StoveRecipeRegistry();
|
||||||
|
private Map ORIGINAL_PRODUCT_MAP = new HashMap();
|
||||||
|
private Map PRODUCT_XP_MAP = new HashMap();
|
||||||
|
|
||||||
|
public static StoveRecipeRegistry getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private StoveRecipeRegistry() {
|
||||||
|
this.addItem(Items.EGG, new ItemStack(ModItems.COOKED_EGG), 0.35F);
|
||||||
|
|
||||||
|
/*for(FishType var4 : FishType.values()) {
|
||||||
|
if (var4.method_6359()) {
|
||||||
|
this.addItemStack(new ItemStack(Items.RAW_FISH, 1, var4.getMeta()), new ItemStack(Items.field_7018, 1, var4.getMeta()), 0.35F);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBlock(Block block, ItemStack stack, float xp) {
|
||||||
|
this.addItem(Item.fromBlock(block), stack, xp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addItem(Item item, ItemStack stack, float xp) {
|
||||||
|
this.addItemStack(new ItemStack(item, 1, 32767), stack, xp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addItemStack(ItemStack original, ItemStack product, float xp) {
|
||||||
|
this.ORIGINAL_PRODUCT_MAP.put(original, product);
|
||||||
|
this.PRODUCT_XP_MAP.put(product, xp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public ItemStack getResult(ItemStack stack) {
|
||||||
|
for(Object var3 : this.ORIGINAL_PRODUCT_MAP.entrySet()) {
|
||||||
|
if (this.stackEquals(stack, (ItemStack)var3.notify())) {
|
||||||
|
return (ItemStack)var3.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
private boolean stackEquals(ItemStack stack1, ItemStack stack2) {
|
||||||
|
return stack2.getItem() == stack1.getItem() && (stack2.getData() == 32767 || stack2.getData() == stack1.getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map getRecipeMap() {
|
||||||
|
return this.ORIGINAL_PRODUCT_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public float getXp(ItemStack stack) {
|
||||||
|
for(Map.Entry var3 : this.PRODUCT_XP_MAP.entrySet()) {
|
||||||
|
if (this.stackEquals(stack, (ItemStack)var3.getKey())) {
|
||||||
|
return var3.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0F;
|
||||||
|
}*/
|
||||||
|
}
|
67
remappedSrc/xyz/limepot/emb/recipe/StoveRecipeType.java
Normal file
67
remappedSrc/xyz/limepot/emb/recipe/StoveRecipeType.java
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
package xyz.limepot.emb.recipe;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import xyz.limepot.emb.item.ModItems;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static java.util.Map.*;
|
||||||
|
|
||||||
|
public class StoveRecipeType {
|
||||||
|
private static final StoveRecipeType INSTANCE = new StoveRecipeType();
|
||||||
|
private Map ORIGINAL_PRODUCT_MAP = new HashMap();
|
||||||
|
private Map PRODUCT_XP_MAP = new HashMap();
|
||||||
|
|
||||||
|
public static StoveRecipeType getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private StoveRecipeType() {
|
||||||
|
this.addItem(Items.EGG, new ItemStack(ModItems.COOKED_EGG), 0.35F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBlock(Block block, ItemStack stack, float xp) {
|
||||||
|
this.addItem(Item.fromBlock(block), stack, xp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addItem(Item item, ItemStack stack, float xp) {
|
||||||
|
this.addItemStack(new ItemStack(item, 1, 32767), stack, xp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addItemStack(ItemStack original, ItemStack product, float xp) {
|
||||||
|
this.ORIGINAL_PRODUCT_MAP.put(original, product);
|
||||||
|
this.PRODUCT_XP_MAP.put(product, xp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public ItemStack getResult(ItemStack stack) {
|
||||||
|
for(Entry var3 : this.ORIGINAL_PRODUCT_MAP.entrySet()) {
|
||||||
|
if (this.stackEquals(stack, (ItemStack)var3.getKey())) {
|
||||||
|
return (ItemStack)var3.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
private boolean stackEquals(ItemStack stack1, ItemStack stack2) {
|
||||||
|
return stack2.getItem() == stack1.getItem() && (stack2.getData() == 32767 || stack2.getData() == stack1.getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map getRecipeMap() {
|
||||||
|
return this.ORIGINAL_PRODUCT_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public float getXp(ItemStack stack) {
|
||||||
|
for(Map.Entry var3 : this.PRODUCT_XP_MAP.entrySet()) {
|
||||||
|
if (this.stackEquals(stack, (ItemStack)var3.getKey())) {
|
||||||
|
return var3.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0F;
|
||||||
|
}*/
|
||||||
|
}
|
120
remappedSrc/xyz/limepot/emb/util/FileUtils.java
Normal file
120
remappedSrc/xyz/limepot/emb/util/FileUtils.java
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
package xyz.limepot.emb.util;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.JarURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.jar.JarEntry;
|
||||||
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
|
public class FileUtils {
|
||||||
|
public static boolean copyFile(final File toCopy, final File destFile) {
|
||||||
|
try {
|
||||||
|
return FileUtils.copyStream(new FileInputStream(toCopy),
|
||||||
|
new FileOutputStream(destFile));
|
||||||
|
} catch (final FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean copyFilesRecusively(final File toCopy,
|
||||||
|
final File destDir) {
|
||||||
|
assert destDir.isDirectory();
|
||||||
|
|
||||||
|
if (!toCopy.isDirectory()) {
|
||||||
|
return FileUtils.copyFile(toCopy, new File(destDir, toCopy.getName()));
|
||||||
|
} else {
|
||||||
|
final File newDestDir = new File(destDir, toCopy.getName());
|
||||||
|
if (!newDestDir.exists() && !newDestDir.mkdir()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (final File child : toCopy.listFiles()) {
|
||||||
|
if (!FileUtils.copyFilesRecusively(child, newDestDir)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean copyJarResourcesRecursively(final File destDir,
|
||||||
|
final JarURLConnection jarConnection) throws IOException {
|
||||||
|
|
||||||
|
final JarFile jarFile = jarConnection.getJarFile();
|
||||||
|
|
||||||
|
for (final Enumeration<JarEntry> e = jarFile.entries(); e.hasMoreElements();) {
|
||||||
|
final JarEntry entry = e.nextElement();
|
||||||
|
if (entry.getName().startsWith(jarConnection.getEntryName())) {
|
||||||
|
final String filename = StringUtils.removeStart(entry.getName(), //
|
||||||
|
jarConnection.getEntryName());
|
||||||
|
|
||||||
|
final File f = new File(destDir, filename);
|
||||||
|
if (!entry.isDirectory()) {
|
||||||
|
final InputStream entryInputStream = jarFile.getInputStream(entry);
|
||||||
|
if(!FileUtils.copyStream(entryInputStream, f)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
entryInputStream.close();
|
||||||
|
} else {
|
||||||
|
if (!FileUtils.ensureDirectoryExists(f)) {
|
||||||
|
throw new IOException("Could not create directory: "
|
||||||
|
+ f.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean copyResourcesRecursively( //
|
||||||
|
final URL originUrl, final File destination) {
|
||||||
|
try {
|
||||||
|
final URLConnection urlConnection = originUrl.openConnection();
|
||||||
|
if (urlConnection instanceof JarURLConnection) {
|
||||||
|
return FileUtils.copyJarResourcesRecursively(destination,
|
||||||
|
(JarURLConnection) urlConnection);
|
||||||
|
} else {
|
||||||
|
return FileUtils.copyFilesRecusively(new File(originUrl.getPath()),
|
||||||
|
destination);
|
||||||
|
}
|
||||||
|
} catch (final IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean copyStream(final InputStream is, final File f) {
|
||||||
|
try {
|
||||||
|
return FileUtils.copyStream(is, new FileOutputStream(f));
|
||||||
|
} catch (final FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean copyStream(final InputStream is, final OutputStream os) {
|
||||||
|
try {
|
||||||
|
final byte[] buf = new byte[1024];
|
||||||
|
|
||||||
|
int len = 0;
|
||||||
|
while ((len = is.read(buf)) > 0) {
|
||||||
|
os.write(buf, 0, len);
|
||||||
|
}
|
||||||
|
is.close();
|
||||||
|
os.close();
|
||||||
|
return true;
|
||||||
|
} catch (final IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean ensureDirectoryExists(final File f) {
|
||||||
|
return f.exists() || f.mkdir();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -109,6 +109,8 @@ public class StoveBlockEntity extends BlockEntity implements SidedInventory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Something is going wrong here "Missing a Mapping, at toNbt", not sure *exactly* what that means but we will figure it out someday.
|
||||||
@Override
|
@Override
|
||||||
public void toNbt(NbtCompound nbt) {
|
public void toNbt(NbtCompound nbt) {
|
||||||
super.toNbt(nbt);
|
super.toNbt(nbt);
|
||||||
|
|
Loading…
Reference in a new issue