Skip to content

Commit

Permalink
炼药正常辣
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuqi154 committed Sep 23, 2024
1 parent b73d806 commit e4b03f8
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,39 +164,39 @@ private static VisceraHolder fromHeart(Heart heart){
return new VisceraHolder(heart.yin(), heart.yang(),heart.ping());
}

private Heart toHeart(){
public Heart toHeart(){
return new Heart(yin, yang,ping);
}

private static VisceraHolder fromKidney(Kidney kidney){
return new VisceraHolder(kidney.yin(), kidney.yang(),kidney.ping());
}

private Kidney toKidney(){
public Kidney toKidney(){
return new Kidney(yin, yang,ping);
}

private static VisceraHolder fromLiver(Liver liver){
return new VisceraHolder(liver.yin(), liver.yang(),liver.ping());
}

private Liver toLiver(){
public Liver toLiver(){
return new Liver(yin, yang,ping);
}

private static VisceraHolder fromLung(Lung lung){
return new VisceraHolder(lung.yin(), lung.yang(),lung.ping());
}

private Lung toLung(){
public Lung toLung(){
return new Lung(yin, yang,ping);
}

private static VisceraHolder fromSpleen(Spleen spleen){
return new VisceraHolder(spleen.yin(), spleen.yang(),spleen.ping());
}

private Spleen toSpleen(){
public Spleen toSpleen(){
return new Spleen(yin, yang,ping);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
import org.hiedacamellia.whispergrove.core.recipe.generalprescriptprocess.GeneralPrescriptProcessApplier;
import org.hiedacamellia.whispergrove.core.recipe.generalprescriptprocess.GeneralPrescriptProcessRecipe;
import org.hiedacamellia.whispergrove.registers.WGBlockEntity;
import org.hiedacamellia.whispergrove.registers.WGItem;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;

public class SpringingBlockEntity extends WGTickableBlockEntity {
Expand Down Expand Up @@ -56,8 +59,14 @@ public void assemble(BlockState state, Level level, BlockPos pos, RandomSource r
Debug.getLogger().debug("Assembling");
Debug.getLogger().debug("stacks: "+stacks);
ItemStack result = GeneralPrescriptProcessApplier.result(state, stacks.subList(0,8), level);
if(result.isEmpty())
result = GeneralPrescriptProcessRecipe.ass(stacks.subList(0,8),ItemStack.EMPTY);
if(result.isEmpty()) {
Debug.getLogger().debug("result: "+result);
List<ItemStack> inputs = new ArrayList<>(stacks.subList(0, 8));
inputs.removeAll(List.of(ItemStack.EMPTY));
Debug.getLogger().debug("inputs: "+inputs);
result = GeneralPrescriptProcessRecipe.ass(inputs, WGItem.SOUP.toStack());
Debug.getLogger().debug("real_result: "+result);
}
if(result!=null) {
stacks.set(9, result);
Debug.getLogger().debug("set: " + stacks.get(9));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.items.ItemStackHandler;
import org.hiedacamellia.whispergrove.core.config.CommonConfig;
import org.hiedacamellia.whispergrove.api.viscera.VisceraHolder;
import org.hiedacamellia.whispergrove.core.util.ItemStackHolder;
import org.hiedacamellia.whispergrove.registers.WGItem;
import org.hiedacamellia.whispergrove.registers.WGRicipe;
import org.hiedacamellia.whispergrove.registers.WGRicipeSerializer;
Expand Down Expand Up @@ -131,9 +133,10 @@ public boolean matches(GeneralPrescriptProcessInput input, Level level) {

public static ItemStack ass(List<ItemStack> input,ItemStack aresult) {

ItemStack result = aresult;
if(result.isEmpty()){
result = WGItem.SOUP.toStack();
ItemStackHolder holder = new ItemStackHolder(aresult);

if(holder.isEmpty()){
holder.setItemStack(WGItem.SOUP.toStack());
}

VisceraHolder heart = new VisceraHolder();
Expand Down Expand Up @@ -163,32 +166,32 @@ public static ItemStack ass(List<ItemStack> input,ItemStack aresult) {
double visceramass = heartmass+kidneymass+livermass+lungmass+spleenmass;

if(heart.isYang()){
result = heart.getYang(heartmass/visceramass * CommonConfig.VISCERA_CONSTANT.get()).setHeart(result);
holder.setHeart(heart.getYang(heartmass/visceramass * CommonConfig.VISCERA_CONSTANT.get()));
}else {
result =heart.getYin(heartmass/visceramass * CommonConfig.VISCERA_CONSTANT.get()).setHeart(result);
holder.setHeart(heart.getYin(heartmass/visceramass * CommonConfig.VISCERA_CONSTANT.get()));
}
if(kidney.isYang()){
result =kidney.getYang(kidneymass/visceramass * CommonConfig.VISCERA_CONSTANT.get()).setKidney(result);
holder.setKidney(kidney.getYang(kidneymass/visceramass * CommonConfig.VISCERA_CONSTANT.get()));
}else {
result =kidney.getYin(kidneymass/visceramass * CommonConfig.VISCERA_CONSTANT.get()).setKidney(result);
holder.setKidney(kidney.getYin(kidneymass/visceramass * CommonConfig.VISCERA_CONSTANT.get()));
}
if(liver.isYang()){
result =liver.getYang(livermass/visceramass * CommonConfig.VISCERA_CONSTANT.get()).setLiver(result);
holder.setLiver(liver.getYang(livermass/visceramass * CommonConfig.VISCERA_CONSTANT.get()));
}else {
result =liver.getYin(livermass/visceramass * CommonConfig.VISCERA_CONSTANT.get()).setLiver(result);
holder.setLiver(liver.getYin(livermass/visceramass * CommonConfig.VISCERA_CONSTANT.get()));
}
if(lung.isYang()){
result =lung.getYang(lungmass/visceramass * CommonConfig.VISCERA_CONSTANT.get()).setLung(result);
holder.setLung(lung.getYang(lungmass/visceramass * CommonConfig.VISCERA_CONSTANT.get()));
}else {
result =lung.getYin(lungmass/visceramass * CommonConfig.VISCERA_CONSTANT.get()).setLung(result);
holder.setLung(lung.getYin(lungmass/visceramass * CommonConfig.VISCERA_CONSTANT.get()));
}
if(spleen.isYang()){
result =spleen.getYang(spleenmass/visceramass * CommonConfig.VISCERA_CONSTANT.get()).setSpleen(result);
holder.setSpleen(spleen.getYang(spleenmass/visceramass * CommonConfig.VISCERA_CONSTANT.get()));
}else {
result =spleen.getYin(spleenmass/visceramass * CommonConfig.VISCERA_CONSTANT.get()).setSpleen(result);
holder.setSpleen(spleen.getYin(spleenmass/visceramass * CommonConfig.VISCERA_CONSTANT.get()));
}

return result;
return holder.getItemStack();
}

// This example outlines the most important methods. There is a number of other methods to override.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static List<Component> fromItemStack(ItemStack itemStack) {
private static Component getComponent(Component c, double yin, double yang, double ping) {
Component component = c.copy();
if (yin != 0) {
component = component.copy().append(Component.translatable("tooltip.whispergrove.yin", (int) yin)).withStyle(ChatFormatting.BLUE);
component = component.copy().append(Component.translatable("tooltip.whispergrove.yin", (int) yin).withStyle(ChatFormatting.BLUE));
} else if (yang != 0) {
component = component.copy().append(Component.translatable("tooltip.whispergrove.yang", (int) yang).withStyle(ChatFormatting.RED));
} else if(ping!= 0){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.hiedacamellia.whispergrove.core.util;

import net.minecraft.world.item.ItemStack;
import org.hiedacamellia.whispergrove.api.viscera.VisceraHolder;
import org.hiedacamellia.whispergrove.registers.WGDataComponent;

public class ItemStackHolder {
private ItemStack itemStack;

public ItemStackHolder(ItemStack itemStack) {
this.itemStack = itemStack;
}

public ItemStackHolder() {
this.itemStack = ItemStack.EMPTY;
}

public ItemStack getItemStack() {
return itemStack;
}

public void setItemStack(ItemStack itemStack) {
this.itemStack = itemStack;
}

public boolean isEmpty() {
return itemStack.isEmpty();
}

public void setHeart(VisceraHolder holder) {
itemStack.set(WGDataComponent.HEART.get(), holder.toHeart());
}

public void setKidney(VisceraHolder holder){
itemStack.set(WGDataComponent.KIDNEY.get(), holder.toKidney());
}

public void setLiver(VisceraHolder holder){
itemStack.set(WGDataComponent.LIVER.get(), holder.toLiver());
}

public void setLung(VisceraHolder holder){
itemStack.set(WGDataComponent.LUNG.get(), holder.toLung());
}

public void setSpleen(VisceraHolder holder){
itemStack.set(WGDataComponent.SPLEEN.get(), holder.toSpleen());
}

}
Binary file modified src/main/resources/assets/whispergrove/textures/item/soup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e4b03f8

Please sign in to comment.