Skip to content

Commit

Permalink
fixed several bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Takakura-Anri committed Jun 14, 2021
1 parent b6a5493 commit 59f2d0e
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 26 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx3G

# FoodCraft Reloaded Mod Properties
mod_id = foodcraftreloaded
mod_version = 1.0.2-EA
mod_version = 1.0.3-EA
mod_group = com.projecturanus.foodcraft

# Minecraft & Forge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ val MACHINE_MATERIAL = object : Material(MapColor.IRON) {
override fun isOpaque() = false
}

abstract class BlockMachine : BlockHorizontal(Material.IRON), ITileEntityProvider {
abstract class BlockMachine : BlockHorizontal(MACHINE_MATERIAL), ITileEntityProvider {

init {
creativeTab = FcTabMachine
defaultState = blockState.baseState.withProperty(FACING, EnumFacing.NORTH).withProperty(WORKING, false)
setHardness(4.0f)
setHarvestLevel("pickaxe", 1)
}

override fun createBlockState(): BlockStateContainer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.projecturanus.foodcraft.common.block.container

import com.projecturanus.foodcraft.MODID
import com.projecturanus.foodcraft.common.block.container.slot.SlotOutput
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.entity.player.InventoryPlayer
import net.minecraft.inventory.Slot
import net.minecraft.item.ItemStack
Expand Down Expand Up @@ -40,5 +41,34 @@ class ContainerChoppingBoard(playerInventory: InventoryPlayer, tileEntity: TileE
}
}

override fun transferStackInSlot(playerIn: EntityPlayer, index: Int): ItemStack {
val slot = inventorySlots[index]
var stack = ItemStack.EMPTY
// Checks for an empty slot
if (slot == null || !slot.hasStack) return stack
stack = slot.stack.copy()
when (index) {
0 -> { // Fuel slot
if (!mergeItemStack(slot.stack, 1, 37, true))
return ItemStack.EMPTY
slot.onSlotChange(slot.stack, stack)
}
in 4..30 -> { // Player inventory (exclude hotbar)
if (mergeItemStack(slot.stack, 0, 1, false))
return ItemStack.EMPTY
else if (mergeItemStack(slot.stack, 28, 37, false))
return ItemStack.EMPTY
}
in 31..39 -> { // Hotbar
if (mergeItemStack(slot.stack, 0, 1, false))
return ItemStack.EMPTY
else if (mergeItemStack(slot.stack, 1, 28, false))
return ItemStack.EMPTY
}
}
if (stack.isEmpty) slot.putStack(ItemStack.EMPTY)
return stack
}

override fun getName(): String = "tile.$MODID.chopping_board.name"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.projecturanus.foodcraft.MODID
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.entity.player.InventoryPlayer
import net.minecraft.inventory.Container
import net.minecraft.item.ItemStack
import net.minecraft.tileentity.TileEntity
import net.minecraft.util.text.ITextComponent
import net.minecraft.util.text.TextComponentString
Expand Down Expand Up @@ -33,4 +34,8 @@ open class ContainerMachine(val playerInventory: InventoryPlayer, open val tileE
@SideOnly(Side.CLIENT)
override fun updateProgressBar(id: Int, data: Int) {
}

override fun transferStackInSlot(playerIn: EntityPlayer, index: Int): ItemStack {
return ItemStack.EMPTY
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ abstract class TileEntityFluidRecipeMachine<T>(recipeRegistry: IForgeRegistry<T>
fluidTank.setCanDrain(true)
fluidTank.contentChangedListener += {
loadFluid(fluidHandlerSlot)
if (recipe == null && progress == 0) recipe = findRecipe()
}
inventory.contentChangedListener += {
if (it == fluidHandlerSlot) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ abstract class TileEntityMachine(val slots: Int) : TileEntity(), ITickable {
}

override fun update() {

}

@Suppress("UNCHECKED_CAST")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class TileEntityRecipeMachine<T>(val recipeRegistry: IForgeRegistry<T>,
inventory.contentChangedListener += {
if (it in inputSlots || it in outputSlots) {
// When there is only one item left in machine, do not lookup recipes again
if (recipe == null) recipe = findRecipe()
if (recipe == null && progress == 0) recipe = findRecipe()
}
}
inventory.validation = { slot, stack ->
Expand All @@ -52,12 +52,12 @@ abstract class TileEntityRecipeMachine<T>(val recipeRegistry: IForgeRegistry<T>,
// Finish
if (canFinish()) {
// Reset
var stack = recipe?.getRecipeOutput()?.copy()?: ItemStack.EMPTY
progress = 0

consumeInput()
reset()
working = false
var stack = recipe?.getRecipeOutput()?.copy()?: ItemStack.EMPTY
outputSlots.forEach { slot ->
stack = inventory.insertItem(slot, stack, false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ object RegisterHandler {
adzukiBeanBlock = this
},
BlockBeverageMaking().setRegistryName(MODID, "beverage_making").setTranslationKey("$MODID.beverage_making").itemBlock(),
BlockBrewBarrel().setRegistryName(MODID, "brew_barrel").setTranslationKey("$MODID.brew_barrel").itemBlock(),
BlockChoppingBoard().setRegistryName(MODID, "chopping_board").setTranslationKey("$MODID.chopping_board").itemBlock(),
BlockBrewBarrel().also { it.setHarvestLevel("axe", 0) }.setRegistryName(MODID, "brew_barrel").setTranslationKey("$MODID.brew_barrel").itemBlock(),
BlockChoppingBoard().also { it.setHarvestLevel("axe", 0) }.setRegistryName(MODID, "chopping_board").setTranslationKey("$MODID.chopping_board").itemBlock(),
BlockFryingPan().setRegistryName(MODID, "frying_pan").setTranslationKey("$MODID.frying_pan").itemBlock(),
BlockMill().setRegistryName(MODID, "mill").setTranslationKey("$MODID.mill").itemBlock(),
BlockPan().setRegistryName(MODID, "pan").setTranslationKey("$MODID.pan").itemBlock(),
BlockPot().setRegistryName(MODID, "pot").setTranslationKey("$MODID.pot").itemBlock(),
BlockPressureCooker().setRegistryName(MODID, "pressure_cooker").setTranslationKey("$MODID.pressure_cooker").itemBlock(),
BlockStove().setRegistryName(MODID, "stove").setTranslationKey("$MODID.stove").itemBlock(),
Block(Material.ROCK).setRegistryName(MODID, "machine_casing").setTranslationKey("$MODID.machine_casing").itemBlock(),
Block(Material.ROCK).also { it.setHarvestLevel("pickaxe", 1) }.setHardness(4.0f).setRegistryName(MODID, "machine_casing").setTranslationKey("$MODID.machine_casing").itemBlock(),
BlockFluidClassic(FluidMilk, Material.WATER).setRegistryName(MODID, "milk").setTranslationKey("$MODID.milk"),
BlockFluidClassic(FluidCookingOil, Material.WATER).setRegistryName(MODID, "cooking_oil").setTranslationKey("$MODID.cooking_oil")
)
Expand Down Expand Up @@ -570,6 +570,7 @@ object RegisterHandler {
drink("tea", 6, Color(0x98a285), -1, "foodTea")
drink("milk_tea", 7, Color(0xc29833), -1, "foodMilktea")
drink("coffee", 7, Color(0x50462d), -1, "foodCoffee")
drink("sugar_with_water", 2, Color(16777215), -1)
drinkColorables.forEach {
drink("${it}_juice", 7, it.color, -1, "listAlljuice", "food${it.toString().capitalize()}juice").apply {
realTranslationKey = "item.$MODID.$it.name"
Expand All @@ -582,7 +583,7 @@ object RegisterHandler {
// Ice-creams
food(event.registry, "original_ice_cream", 5, 3f) { creativeTab = FcTabDrink; DEFAULT_MODEL_ITEMS += this }

val iceCreamColorables = arrayOf<Colorable>(LITCHI, PEACH, ORANGE, MANGO, LEMON, PAPAYA, PERSIMMON, BANANA, COCONUT, STRAWBERRY)
val iceCreamColorables = arrayOf<Colorable>(LITCHI, PEACH, PEAR, ORANGE, MANGO, LEMON, PAPAYA, PERSIMMON, BANANA, COCONUT, STRAWBERRY)
iceCreamColorables.forEach {
iceCream("${it}_ice_cream", it.color, "food${it.toString().capitalize()}icecream").apply {
realTranslationKey = "item.$MODID.$it.name"
Expand All @@ -596,6 +597,22 @@ object RegisterHandler {
}
}

iceCream("carrot_ice_cream", Color(0xf4872f), "foodCarroticecream", "listAllicecream").apply {
realTranslationKey = "item.carrot.name"
hasSuffix = true
baseTranslationKey = "item.$MODID.ice_cream.name"
}
iceCream("apple_ice_cream", Color(0xfa2059), "foodAppleicecream", "listAllicecream").apply {
realTranslationKey = "item.apple.name"
hasSuffix = true
baseTranslationKey = "item.$MODID.ice_cream.name"
}
iceCream("melon_ice_cream", Color(0xe848b9), "foodMelonicecream", "listAllicecream").apply {
realTranslationKey = "tile.melon_block.name"
hasSuffix = true
baseTranslationKey = "item.$MODID.ice_cream.name"
}

liqueur("wine", Color(0x722f37))
liqueur("spirit", Color(0xffffff))
val liqueurColorables = arrayOf(GRAPE, LITCHI, PEACH, MANGO, LEMON, POMEGRANATE)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.projecturanus.foodcraft.common.item

import com.projecturanus.foodcraft.MODID
import com.projecturanus.foodcraft.common.init.FCRItems
import net.minecraft.client.renderer.block.model.ModelResourceLocation
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.EnumAction
Expand All @@ -23,7 +22,7 @@ open class ItemDrink(color: Color) : ItemMasked(color, ModelResourceLocation(Res
player.addPotionEffect(PotionEffect(potions.value[world.rand.nextInt(potions.value.size)]))
}
}
player.addItemStackToInventory(ItemStack(FCRItems.GLASS_CUP))
//player.addItemStackToInventory(ItemStack(FCRItems.GLASS_CUP))
}
}
}
18 changes: 14 additions & 4 deletions src/main/resources/assets/foodcraftreloaded/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,17 @@ item.foodcraftreloaded.mango.name=Mango
item.foodcraftreloaded.lemon.name=Lemon
item.foodcraftreloaded.grape.name=Grape
item.foodcraftreloaded.persimmon.name=Persimmon
item.foodcraftreloaded.papaya=Papaya
item.foodcraftreloaded.hawthorn=Hawthorn
item.foodcraftreloaded.pomegranate=Pomegranate
item.foodcraftreloaded.papaya.name=Papaya
item.foodcraftreloaded.hawthorn.name=Hawthorn
item.foodcraftreloaded.pomegranate.name=Pomegranate
item.foodcraftreloaded.date.name=Date
item.foodcraftreloaded.cherry.name=Cherry
item.foodcraftreloaded.coconut.name=Coconut
item.foodcraftreloaded.banana.name=Banana
item.foodcraftreloaded.strawberry.name=Strawberry
item.foodcraftreloaded.golden_grape.name=Golden Grape
item.foodcraftreloaded.loquat.name=Loquat
item.foodcraftreloaded.longan.name=Longan

# Vegetable
item.foodcraftreloaded.eggplant.name=Eggplant
Expand Down Expand Up @@ -190,6 +192,13 @@ item.foodcraftreloaded.ginger.name=Ginger
item.foodcraftreloaded.onion.name=Onion
item.foodcraftreloaded.green_onion.name=Green Onion

# Kitchen knife
item.foodcraftreloaded.stone_kitchen_knife.name=Stone Knife
item.foodcraftreloaded.iron_kitchen_knife.name=Iron Knife
item.foodcraftreloaded.gold_kitchen_knife.name=Gold Knife
item.foodcraftreloaded.diamond_kitchen_knife.name=Diamond Knife
item.foodcraftreloaded.emerald_kitchen_knife.name=Emerald Knife

# Sapling
item.foodcraftreloaded.sapling=%s Sapling

Expand All @@ -216,7 +225,8 @@ item.foodcraftreloaded.cola.name=Cola™
item.foodcraftreloaded.tea.name=Tea
item.foodcraftreloaded.milk_tea.name=Milk Tea
item.foodcraftreloaded.coffee.name=Coffee

item.foodcraftreloaded.sprite.name=Sprite™
item.foodcraftreloaded.sugar_with_water.name=Sugar with Water

# Soda
item.foodcraftreloaded.soda=%s Soda
Expand Down
12 changes: 8 additions & 4 deletions src/main/resources/assets/foodcraftreloaded/lang/zh_cn.lang
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ item.foodcraftreloaded.coconut.name=椰子
item.foodcraftreloaded.banana.name=香蕉
item.foodcraftreloaded.strawberry.name=草莓
item.foodcraftreloaded.golden_grape.name=金葡萄
item.foodcraftreloaded.loquat.name=枇杷
item.foodcraftreloaded.longan.name=龙眼

# Vegetable
item.foodcraftreloaded.eggplant.name=茄子
Expand Down Expand Up @@ -207,10 +209,10 @@ item.foodcraftreloaded.green_onion.name=葱

# Kitchen knife
item.foodcraftreloaded.stone_kitchen_knife.name=石刀
item.foodcraftreloaded.iron_kitchenKnifeIron.name=铁刀
item.foodcraftreloaded.gold_kitchenKnifeGold.name=金刀
item.foodcraftreloaded.diamond_kitchenKnifeDiamond.name=钻石刀
item.foodcraftreloaded.emerald_kitchenKnifeEmerald.name=绿宝石刀
item.foodcraftreloaded.iron_kitchen_knife.name=铁刀
item.foodcraftreloaded.gold_kitchen_knife.name=金刀
item.foodcraftreloaded.diamond_kitchen_knife.name=钻石刀
item.foodcraftreloaded.emerald_kitchen_knife.name=绿宝石刀

# Sapling
item.foodcraftreloaded.sapling=%s树苗
Expand Down Expand Up @@ -238,6 +240,8 @@ item.foodcraftreloaded.cola.name=可乐™
item.foodcraftreloaded.tea.name=茶
item.foodcraftreloaded.milk_tea.name=奶茶
item.foodcraftreloaded.coffee.name=咖啡
item.foodcraftreloaded.sprite.name=雪碧
item.foodcraftreloaded.sugar_with_water.name=白糖兑水

# Cookie
item.foodcraftreloaded.sandwich_cookie=%s夹心饼干
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"item/generated","textures":{"layer0":"foodcraftreloaded:items/curry"}}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
},
"A": {
"type": "forge:ore_dict",
"ore": "redstone"
"ore": "dustRedstone"
},
"B": {
"item": "minecraft:ice"
},
"C": {
"type": "forge:ore_dict",
"ore": "circuitBasic"
},
"D": {
"type": "forge:ore_dict",
"ore": "dyeBrowns"
},
"B": {
"item": "minecraft:ice"
"ore": "dyeBrown"
}
},
"result": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"foodcraftreloaded:beverage_making","ingredient":{"item": "minecraft:snowball"},"cool":true,"fluidInput":{"fluid":"milk","amount":1000},"result":{"item":"foodcraftreloaded:original_ice_cream"}}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"key": {
"C": {
"type": "forge:ore_dict",
"ore": "redstone"
"ore": "dustRedstone"
},
"B": {
"type": "forge:ore_dict",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"E": {
"type": "forge:ore_dict",
"ore": "redstone"
"ore": "dustRedstone"
}
},
"result": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"type": "forge:ore_shapeless",
"ingredients": [
{
"type": "forge:ore_dict",
"ore": "listAllsugar"
},
{
"type": "forge:ore_dict",
"ore": "listAllwater"
}
],
"result": {
"item": "foodcraftreloaded:sugar_with_water"
}
}

0 comments on commit 59f2d0e

Please sign in to comment.