Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/Snownee/Cuisine
Browse files Browse the repository at this point in the history
  • Loading branch information
Snownee committed Oct 27, 2018
2 parents 95376fd + 8d556e6 commit e195a07
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/main/java/snownee/cuisine/blocks/BlockBamboo.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public class BlockBamboo extends BlockMod
public static final PropertyBool SE = PropertyBool.create("se");
public static final PropertyBool SW = PropertyBool.create("sw");

public static final AxisAlignedBB PLATE_AABB = new AxisAlignedBB(0.3125D, 0.625D, 0.3125D, 1, 1, 1);
public static final AxisAlignedBB SIDE_AABB = new AxisAlignedBB(0.375D, 0.625D, 0.375D, 1, 0.875D, 0.625D);
private static final AxisAlignedBB PLATE_AABB = new AxisAlignedBB(0.3125D, 0.625D, 0.3125D, 1, 1, 1);
private static final AxisAlignedBB SIDE_AABB = new AxisAlignedBB(0.375D, 0.625D, 0.375D, 1, 0.875D, 0.625D);

public BlockBamboo(String name)
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/snownee/cuisine/items/ItemIngredient.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void mapModel()
@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
Ingredient ingredient = null;
Ingredient ingredient;
if (stack.getTagCompound() != null && entityLiving instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) entityLiving;
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/snownee/cuisine/plugins/BOPCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.oredict.OreDictionary;
import snownee.cuisine.Cuisine;
import snownee.cuisine.api.CulinaryHub;
Expand All @@ -27,51 +29,51 @@ public void init()
CulinaryHub.API_INSTANCE.registerMapping("cropPeach", peach);
Material persimmon = CulinaryHub.API_INSTANCE.register(new SimpleMaterialImpl("persimmon", 0xFF9528, 0, 0, 0, 0, 0, MaterialCategory.FRUIT).setValidForms(Form.JUICE_ONLY));
CulinaryHub.API_INSTANCE.registerMapping("cropPersimmon", persimmon);
Item itemBerry = Item.getByNameOrId("biomesoplenty:berries");
Item itemBerry = ForgeRegistries.ITEMS.getValue(new ResourceLocation("biomesoplenty", "berries"));
if (itemBerry != null)
{
Material wildberry = CulinaryHub.API_INSTANCE.register(new SimpleMaterialImpl("wildberry", 0x4D1F23, 0, 0, 0, 0, 0, MaterialCategory.FRUIT).setValidForms(Form.JUICE_ONLY));
CulinaryHub.API_INSTANCE.registerMapping(ItemDefinition.of(itemBerry), wildberry);
}
Item itemKelp = Item.getByNameOrId("biomesoplenty:seaweed");
Item itemKelp = ForgeRegistries.ITEMS.getValue(new ResourceLocation("biomesoplenty", "seaweed"));
if (itemKelp != null)
{
OreDictionary.registerOre("cropSeaweed", new ItemStack(itemKelp));
Material seaweed = CulinaryHub.API_INSTANCE.register(new SimpleMaterialImpl("seaweed", 0x99909648, 0, 0, 0, 0, 0, MaterialCategory.SEAFOOD).setValidForms(Form.JUICE_ONLY));
CulinaryHub.API_INSTANCE.registerMapping("cropSeaweed", seaweed);
}
Item itemBambooshoot = Item.getByNameOrId("biomesoplenty:sapling_0");
Item itemBambooshoot = ForgeRegistries.ITEMS.getValue(new ResourceLocation("biomesoplenty", "sapling_0"));
if (itemBambooshoot != null)
{
OreDictionary.registerOre("cropBambooshoot", new ItemStack(itemBambooshoot, 1, 2));
}

Item log = Item.getByNameOrId("biomesoplenty:log_0");
Item planks = Item.getByNameOrId("biomesoplenty:planks_0");
Item log = ForgeRegistries.ITEMS.getValue(new ResourceLocation("biomesoplenty", "log_0"));
Item planks = ForgeRegistries.ITEMS.getValue(new ResourceLocation("biomesoplenty", "planks_0"));
if (log != null && planks != null)
{
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 4), new ItemStack(planks, 6, 0)));
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 5), new ItemStack(planks, 6, 1)));
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 6), new ItemStack(planks, 6, 2)));
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 7), new ItemStack(planks, 6, 3)));
}
log = Item.getByNameOrId("biomesoplenty:log_1");
log = ForgeRegistries.ITEMS.getValue(new ResourceLocation("biomesoplenty", "log_1"));
if (log != null && planks != null)
{
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 4), new ItemStack(planks, 6, 4)));
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 5), new ItemStack(planks, 6, 5)));
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 6), new ItemStack(planks, 6, 6)));
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 7), new ItemStack(planks, 6, 7)));
}
log = Item.getByNameOrId("biomesoplenty:log_2");
log = ForgeRegistries.ITEMS.getValue(new ResourceLocation("biomesoplenty", "log_2"));
if (log != null && planks != null)
{
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 4), new ItemStack(planks, 6, 8)));
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 5), new ItemStack(planks, 6, 9)));
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 6), new ItemStack(planks, 6, 10)));
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 7), new ItemStack(planks, 6, 11)));
}
log = Item.getByNameOrId("biomesoplenty:log_3");
log = ForgeRegistries.ITEMS.getValue(new ResourceLocation("biomesoplenty", "log_3"));
if (log != null && planks != null)
{
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 4), new ItemStack(planks, 6, 12)));
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/snownee/cuisine/plugins/DarkUtilsCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import snownee.cuisine.Cuisine;
import snownee.cuisine.api.CulinaryCapabilities;
import snownee.cuisine.util.BaublesWrapper;
Expand All @@ -22,7 +24,7 @@ public class DarkUtilsCompat implements IModule
@Override
public void init()
{
if ((itemGluttonyCharm = Item.getByNameOrId("darkutils:charm_gluttony")) != null)
if ((itemGluttonyCharm = ForgeRegistries.ITEMS.getValue(new ResourceLocation("darkutils", "charm_gluttony"))) != null)
{
MinecraftForge.EVENT_BUS.register(this);
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/snownee/cuisine/plugins/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import javax.annotation.Nullable;

import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import snownee.cuisine.api.CulinaryHub;
import snownee.cuisine.api.Ingredient;
import snownee.cuisine.api.Material;
Expand All @@ -23,7 +25,7 @@ public static Material registerMaterial(Material material, String uid)
@Nullable
public static Material registerMaterial(Material material, String uid, int meta)
{
Item item = Item.getByNameOrId(uid);
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(uid));
if (material != null && item != null)
{
material = CulinaryHub.API_INSTANCE.register(material);
Expand All @@ -40,7 +42,7 @@ public static void registerMapping(Ingredient ingredient, String uid)

public static void registerMapping(Ingredient ingredient, String uid, int meta)
{
Item item = Item.getByNameOrId(uid);
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(uid));
if (ingredient != null && item != null)
{
CulinaryHub.API_INSTANCE.registerMapping(ItemDefinition.of(item, meta), ingredient);
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/snownee/cuisine/plugins/RusticCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import snownee.cuisine.Cuisine;
import snownee.cuisine.api.CulinaryHub;
import snownee.cuisine.api.Form;
Expand All @@ -27,8 +29,8 @@ public void init()
Material wildberry = CulinaryHub.API_INSTANCE.register(new SimpleMaterialImpl("wildberry", 0x4D1F23, 0, 0, 0, 0, 0, MaterialCategory.FRUIT).setValidForms(Form.JUICE_ONLY));
CulinaryHub.API_INSTANCE.registerMapping("cropWildberry", wildberry);

Item log = Item.getByNameOrId("rustic:log");
Item planks = Item.getByNameOrId("rustic:planks");
Item log = ForgeRegistries.ITEMS.getValue(new ResourceLocation("rustic", "log"));
Item planks = ForgeRegistries.ITEMS.getValue(new ResourceLocation("rustic", "planks"));
if (log != null && planks != null)
{
Processing.CHOPPING.add(new Chopping(ItemDefinition.of(log, 0), new ItemStack(planks, 6, 0)));
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/snownee/cuisine/plugins/TANCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import snownee.cuisine.Cuisine;
import snownee.cuisine.api.CompositeFood;
import snownee.cuisine.api.CulinaryCapabilities;
Expand Down Expand Up @@ -60,7 +62,7 @@ public void init()
IBlockState state = TANBlocks.temperature_coil.getStateFromMeta(9);
TileBasinHeatable.registerHeatSource(4, state, new ItemStack(TANBlocks.temperature_coil, 1, 1));

Item juice = Item.getByNameOrId("toughasnails:fruit_juice");
Item juice = ForgeRegistries.ITEMS.getValue(new ResourceLocation("toughasnails", "fruit_juice"));
if (juice != null)
{
juice.setContainerItem(Items.GLASS_BOTTLE);
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/snownee/cuisine/plugins/VFPCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import snownee.cuisine.Cuisine;
import snownee.cuisine.api.CulinaryHub;
import snownee.cuisine.api.Form;
Expand All @@ -14,10 +16,13 @@
@KiwiModule(modid = Cuisine.MODID, name = "vanillafoodpantry", dependency = "vanillafoodpantry", optional = true)
public class VFPCompat implements IModule
{

private static final ResourceLocation VFP_JUICE_ID = new ResourceLocation("vanillafoodpantry", "juice");

@Override
public void init()
{
Item juice = Item.getByNameOrId("vanillafoodpantry:juice");
Item juice = ForgeRegistries.ITEMS.getValue(VFP_JUICE_ID);
if (juice != null)
{
juice.setContainerItem(Items.GLASS_BOTTLE);
Expand All @@ -31,7 +36,7 @@ public void init()
@Override
public void postInit()
{
Item juice = Item.getByNameOrId("vanillafoodpantry:juice");
Item juice = ForgeRegistries.ITEMS.getValue(VFP_JUICE_ID);
if (juice != null)
{
// Sad truth: we cannot ensure grape material are registered before VFPCompat#init
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/snownee/cuisine/tiles/TileBasin.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void spillFluids()
public FluidStack getFluidForRendering(float partialTicks)
{
final FluidStack actual = tank.getFluid();
int actualAmount = 0;
int actualAmount;
if (actual != null && !actual.equals(liquidForRendering))
{
liquidForRendering = new FluidStack(actual, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/snownee/cuisine/tiles/TileChoppingBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ else if (isAxe)
}
}

public static ItemStack craftMaterial(ItemStack raw, Ingredient ingredient, int[] actions, boolean fewerLosses, Random rand)
private static ItemStack craftMaterial(ItemStack raw, Ingredient ingredient, int[] actions, boolean fewerLosses, Random rand)
{
Form form = Form.byActions(actions[0], actions[1]);
if (ingredient.getMaterial().isValidForm(form))
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/snownee/cuisine/tiles/TileInventoryBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected void onContentsChanged(int slot)
}
}

public StackHandler stacks;
public final StackHandler stacks;

@SuppressWarnings("deprecation")
public TileInventoryBase(int slot)
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/snownee/cuisine/tiles/TileJar.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@

public class TileJar extends TileInventoryBase implements ITickable
{

private static final int TOTAL_TICK = 1200;

private int processTime = 0;
private boolean isWorking = false;
private static final int TOTAL_TICK = 1200;
private boolean invLock = false;

private FluidTank tank = new FluidTank(10000)
private final FluidTank tank = new FluidTank(10000)
{
@Override
protected void onContentsChanged()
Expand Down
39 changes: 34 additions & 5 deletions src/main/java/snownee/cuisine/tiles/TileSqueezer.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ private enum State
*/
private static final ResourceLocation STATE_MACHINE = new ResourceLocation(Cuisine.MODID, "asms/squeezer.json");

private IAnimationStateMachine stateMachine;
private final IAnimationStateMachine stateMachine;

private TimeValues.VariableValue extensionOffset = new TimeValues.VariableValue(0F);
private final TimeValues.VariableValue extensionOffset = new TimeValues.VariableValue(0F);

private int extensionProgress;

Expand All @@ -67,6 +67,7 @@ public void update()
{
if (state == State.EXTRACTED || state == State.EXTRACTING)
{
this.isInWorkCycle = this.state == State.EXTRACTED;
this.state = State.EXTENDING;
this.animationTransition("moving");
}
Expand All @@ -87,7 +88,6 @@ public void update()
{
extensionProgress = 100;
this.state = State.EXTENDED;
this.isInWorkCycle = true;
if (!world.isRemote)
{
world.playSound(null, pos, SoundEvents.BLOCK_PISTON_EXTEND, SoundCategory.BLOCKS, 0.5F, world.rand.nextFloat() / 4 + .6F);
Expand Down Expand Up @@ -115,7 +115,7 @@ else if (this.state == State.EXTRACTING)
}
}

if (isInWorkCycle)
if (this.state == State.EXTENDED && this.isInWorkCycle)
{
this.isInWorkCycle = false;
if (!world.isRemote)
Expand All @@ -129,7 +129,7 @@ else if (this.state == State.EXTRACTING)
}
}

extensionOffset.setValue((extensionProgress + Animation.getPartialTickTime()) / 100F * OFFSET_LIMIT);
this.updateOffset();
}

private void animationTransition(String newStateName)
Expand All @@ -140,12 +140,40 @@ private void animationTransition(String newStateName)
}
}

private void updateOffset()
{
if (this.world.isRemote)
{
this.extensionOffset.setValue((extensionProgress + Animation.getPartialTickTime()) / 100F * OFFSET_LIMIT);
}
}

@Override
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
this.extensionProgress = compound.getInteger("Extension");
this.state = State.values()[compound.getInteger("State")];
this.isInWorkCycle = compound.getBoolean("WorkCycle");
/*
* You might want to ask why we don't do this in onLoad. The cruel fact is that,
* TileEntity.handleUpdateTag is called after TileEntity.onLoad, where we get
* the correct data used for animation. When onLoad is called, the data on
* client is still incorrect (i.e. not the data received from server after chunk
* loaded and the chunk data are synced over).
* See TileMill.readFromNBT for a similar example.
*/
if (this.world != null && this.world.isRemote)
{
if (this.state != State.EXTRACTED)
{
this.updateOffset();
if (!"moving".equals(this.stateMachine.currentState()))
{
this.stateMachine.transition("moving");
}
}
}
}

@Nonnull
Expand All @@ -154,6 +182,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound compound)
{
compound.setInteger("Extension", this.extensionProgress);
compound.setInteger("State", this.state.ordinal());
compound.setBoolean("WorkCycle", this.isInWorkCycle);
return super.writeToNBT(compound);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/cuisine/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ tile.cuisine.earthen_basin.12.name=Brown-Colored Earthen Basin
tile.cuisine.earthen_basin.13.name=Green-Colored Earthen Basin
tile.cuisine.earthen_basin.14.name=Red-Colored Earthen Basin
tile.cuisine.earthen_basin.15.name=Black-Colored Earthen Basin
tile.cuisine.drinkro.name=Drinkro™
tile.cuisine.drinkro.name=Drinkro™ [WIP]
tile.cuisine.tofu_block.name=Tofu Block
tile.cuisine.tofu_block.tip=Soymilk will solidify into tofu block when touching water; break tofu block to get tofu.
tile.cuisine.chopping_board.name=Chopping Board
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/cuisine/lang/zh_cn.lang
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ tile.cuisine.earthen_basin.12.name=棕色陶盆
tile.cuisine.earthen_basin.13.name=绿色陶盆
tile.cuisine.earthen_basin.14.name=红色陶盆
tile.cuisine.earthen_basin.15.name=黑色陶盆
tile.cuisine.drinkro.name=Drinkro™
tile.cuisine.drinkro.name=Drinkro™ [WIP]
tile.cuisine.tofu_block.name=豆腐块
tile.cuisine.tofu_block.tip=豆浆触碰到醋或粗盐后会变为豆腐块。破坏后掉落豆腐食材。
tile.cuisine.chopping_board.name=砧板
Expand Down

0 comments on commit e195a07

Please sign in to comment.