diff --git a/build.gradle b/build.gradle index b3189c7a..17a77aca 100644 --- a/build.gradle +++ b/build.gradle @@ -119,9 +119,8 @@ repositories { mavenLocal() mavenCentral() // maven { url "https://maven.shedaniel.me" } - maven { - url "https://www.khjxiaogu.com/maven" - } + //khjxiaogu public maven + maven { url "https://www.khjxiaogu.com/maven" } exclusiveContent { forRepository { maven { @@ -135,10 +134,9 @@ repositories { //for patchouli books and jei maven { url 'https://maven.blamejared.com' } - maven { - url "https://maven.architectury.dev/" - } - + maven { url "https://maven.architectury.dev/" } + //for top + maven { url "https://maven.k-4u.nl" } maven { url "https://maven.saps.dev/minecraft" content { @@ -153,6 +151,7 @@ configurations { dependencies { //minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation "net.neoforged:neoforge:${neo_version}" + implementation "mcjty.theoneprobe:theoneprobe:${top_version}" //implementation fg.deobf("curse.maven:diet-443570:3758891") //compileOnly fg.deobf("mezz.jei:jei-1.19.2-common-api:11.2.0.247") diff --git a/gradle.properties b/gradle.properties index f97ca860..a2f91e18 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,6 +25,7 @@ neogradle.subsystems.parchment.mappingsVersion=2024.07.07 mc_version=1.21 minecraft_version=1.21.1 version_neogradle=7.0.161 +top_version=1.21_neo-12.0.3-5 #mod info mod_id=caupona diff --git a/src/main/java/com/teammoeg/caupona/CPMain.java b/src/main/java/com/teammoeg/caupona/CPMain.java index 03a3b20c..0c0f419f 100644 --- a/src/main/java/com/teammoeg/caupona/CPMain.java +++ b/src/main/java/com/teammoeg/caupona/CPMain.java @@ -21,20 +21,27 @@ package com.teammoeg.caupona; +import java.util.function.Consumer; +import java.util.function.Function; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.teammoeg.caupona.client.CPParticles; +import com.teammoeg.caupona.compat.top.TOPRegister; import com.teammoeg.caupona.network.PacketHandler; import com.teammoeg.caupona.util.FuelType; import com.teammoeg.caupona.util.Utils; +import mcjty.theoneprobe.api.ITheOneProbe; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.ItemStack; import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.InterModComms; +import net.neoforged.fml.InterModComms.IMCMessage; import net.neoforged.fml.common.Mod; import net.neoforged.fml.event.lifecycle.InterModEnqueueEvent; import net.neoforged.neoforge.common.NeoForgeMod; @@ -84,6 +91,7 @@ public CPMain(IEventBus mod) { @SuppressWarnings("unused") public void enqueueIMC(InterModEnqueueEvent event) { + InterModComms.sendTo("theoneprobe", "getTheOneProbe", ()->(Function)TOPRegister::register); // InterModComms.sendTo("treechop", "getTreeChopAPI", () -> (Consumer)TreechopCompat::new); } } diff --git a/src/main/java/com/teammoeg/caupona/blocks/dolium/CounterDoliumBlockEntity.java b/src/main/java/com/teammoeg/caupona/blocks/dolium/CounterDoliumBlockEntity.java index 75bb6c42..3e445e7b 100644 --- a/src/main/java/com/teammoeg/caupona/blocks/dolium/CounterDoliumBlockEntity.java +++ b/src/main/java/com/teammoeg/caupona/blocks/dolium/CounterDoliumBlockEntity.java @@ -32,6 +32,7 @@ import com.teammoeg.caupona.network.CPBaseBlockEntity; import com.teammoeg.caupona.util.IInfinitable; import com.teammoeg.caupona.util.LazyTickWorker; +import com.teammoeg.caupona.util.RecipeHandler; import com.teammoeg.caupona.util.SyncedFluidHandler; import com.teammoeg.caupona.util.Utils; @@ -77,7 +78,8 @@ public boolean isItemValid(int slot, ItemStack stack) { @Override protected void onContentsChanged(int slot) { if(slot<5&&slot!=3) - recipeTested=false; + recipeHandler.onContainerChanged(); + setChanged(); super.onContentsChanged(slot); } @@ -87,8 +89,9 @@ protected void onContentsChanged(int slot) { @Override protected void onContentsChanged() { super.onContentsChanged(); - recipeTested=false; - process = -1; + recipeHandler.onContainerChanged(); + recipeHandler.resetProgress(); + syncData(); } }; @@ -114,12 +117,15 @@ private FluidStack tryAddSpice(FluidStack fs) { return fs; } - public int process; - public int processMax; public LazyTickWorker contain; boolean isInfinite = false; ItemStack inner = ItemStack.EMPTY; - boolean recipeTested=false; + public final RecipeHandler recipeHandler=new RecipeHandler<>(()->{ + RecipeHolder recipe = DoliumRecipe.testDolium(tank.getFluid(), inv); + if(recipe!=null) { + inner=recipe.value().handleDolium(tank.getFluid(), inv); + } + }); ResourceLocation lastRecipe; public CounterDoliumBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { super(CPBlockEntityTypes.DOLIUM.get(), pWorldPosition, pBlockState); @@ -142,8 +148,7 @@ public void handleMessage(short type, int data) { @Override public void readCustomNBT(CompoundTag nbt, boolean isClient,HolderLookup.Provider ra) { - process=nbt.getInt("process"); - processMax=nbt.getInt("processMax"); + recipeHandler.readCustomNBT(nbt, isClient); tank.readFromNBT(ra,nbt.getCompound("tank")); isInfinite = nbt.getBoolean("inf"); if (!isClient) { @@ -159,8 +164,7 @@ public void readCustomNBT(CompoundTag nbt, boolean isClient,HolderLookup.Provide @Override public void writeCustomNBT(CompoundTag nbt, boolean isClient,HolderLookup.Provider ra) { - nbt.putInt("process",process); - nbt.putInt("processMax",processMax); + recipeHandler.writeCustomNBT(nbt, isClient); nbt.put("tank", tank.writeToNBT(ra,new CompoundTag())); nbt.putBoolean("inf", isInfinite); if (!isClient) { @@ -183,32 +187,12 @@ public void tick() { this.setChanged(); return; } - if(!recipeTested) { + if(recipeHandler.shouldTestRecipe()){ RecipeHolder recipe=DoliumRecipe.testDolium(tank.getFluid(), inv); - if (recipe!= null) { - if(!recipe.id().equals(lastRecipe)) { - process=processMax=recipe.value().time; - lastRecipe=recipe.id(); - } - }else { - process=processMax=0; - lastRecipe=null; - } + recipeHandler.setRecipe(recipe); - recipeTested=true; } - if (process > 0) { - process--; - if(process<=0) { - RecipeHolder recipe = DoliumRecipe.testDolium(tank.getFluid(), inv); - if(recipe!=null) { - inner=recipe.value().handleDolium(tank.getFluid(), inv); - }else { - process=processMax=0; - } - lastRecipe=null; - recipeTested=false; - } + if (recipeHandler.tickProcess(1)) { updateNeeded=true; } } @@ -381,4 +365,9 @@ public Object getCapability(BlockCapability cap, Direction side) { return null; } + @Override + public boolean isInfinite() { + return isInfinite; + } + } diff --git a/src/main/java/com/teammoeg/caupona/blocks/foods/BowlBlock.java b/src/main/java/com/teammoeg/caupona/blocks/foods/BowlBlock.java index 0c14dd8a..e0a2845c 100644 --- a/src/main/java/com/teammoeg/caupona/blocks/foods/BowlBlock.java +++ b/src/main/java/com/teammoeg/caupona/blocks/foods/BowlBlock.java @@ -34,6 +34,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; @@ -72,7 +73,7 @@ public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, @Override public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (state.getBlock() != newState.getBlock() && worldIn.getBlockEntity(pos) instanceof BowlBlockEntity bowl) { - super.popResource(worldIn, pos, bowl.internal); + super.popResource(worldIn, pos, bowl.getInternal()); } super.onRemove(state, worldIn, pos, newState, isMoving); } @@ -83,19 +84,19 @@ public InteractionResult useWithoutItem(BlockState state, Level worldIn, BlockPo InteractionResult p = super.useWithoutItem(state, worldIn, pos, player, hit); if (p.consumesAction()) return p; - if (worldIn.getBlockEntity(pos) instanceof BowlBlockEntity bowl&&bowl.internal != null && bowl.internal.getItem() instanceof StewItem - && bowl.internal.getFoodProperties(player)!=null) { - FoodProperties fp = bowl.internal.getFoodProperties(player); + if (worldIn.getBlockEntity(pos) instanceof BowlBlockEntity bowl&&bowl.getInternal() != null && bowl.getInternal().getItem() instanceof StewItem + && bowl.getInternal().getFoodProperties(player)!=null) { + FoodProperties fp = bowl.getInternal().getFoodProperties(player); if (bowl.isInfinite) { if (player.canEat(fp.canAlwaysEat())) { - player.eat(worldIn, bowl.internal.copy()); + player.eat(worldIn, bowl.getInternal().copy()); bowl.syncData(); } } else { if (player.canEat(fp.canAlwaysEat())) { - ItemStack iout = player.eat(worldIn, bowl.internal); - bowl.internal = iout; - if(!bowl.internal.isEmpty()) { + ItemStack iout = player.eat(worldIn, bowl.getInternal()); + bowl.setInternal(iout); + if(!bowl.getInternal().isEmpty()) { bowl.syncData(); }else worldIn.removeBlock(pos, false); @@ -111,16 +112,16 @@ public void setPlacedBy(Level pLevel, BlockPos pPos, BlockState pState, LivingEn super.setPlacedBy(pLevel, pPos, pState, pPlacer, pStack); if (pLevel.getBlockEntity(pPos) instanceof BowlBlockEntity bowl) { bowl.setComponents(DataComponentMap.EMPTY); - bowl.internal = pStack.copyWithCount(1); + bowl.setInternal(pStack.copyWithCount(1)); } } - - public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter level, BlockPos pos, + @Override + public ItemStack getCloneItemStack(BlockState state, HitResult target, LevelReader level, BlockPos pos, Player player) { if (level.getBlockEntity(pos) instanceof BowlBlockEntity bowl) { - if (bowl.internal == null) + if (bowl.getInternal() == null) return ItemStack.EMPTY; - return bowl.internal.copy(); + return bowl.getInternal().copy(); } return this.getCloneItemStack(state, target, level, pos, player); } @@ -132,7 +133,7 @@ public boolean hasAnalogOutputSignal(BlockState pState) { @Override public int getAnalogOutputSignal(BlockState pState, Level pLevel, BlockPos pPos) { - if (pLevel.getBlockEntity(pPos) instanceof BowlBlockEntity bowl&&bowl.internal != null && !bowl.internal.isEmpty() && bowl.internal.getFoodProperties(null)!=null) { + if (pLevel.getBlockEntity(pPos) instanceof BowlBlockEntity bowl&&bowl.getInternal() != null && !bowl.getInternal().isEmpty() && bowl.getInternal().getFoodProperties(null)!=null) { return 15; } return 0; diff --git a/src/main/java/com/teammoeg/caupona/blocks/foods/BowlBlockEntity.java b/src/main/java/com/teammoeg/caupona/blocks/foods/BowlBlockEntity.java index ac21e78f..eaa515b5 100644 --- a/src/main/java/com/teammoeg/caupona/blocks/foods/BowlBlockEntity.java +++ b/src/main/java/com/teammoeg/caupona/blocks/foods/BowlBlockEntity.java @@ -34,7 +34,11 @@ import net.minecraft.world.level.block.state.BlockState; public class BowlBlockEntity extends CPBaseBlockEntity implements IInfinitable,IFoodContainer { - public ItemStack internal=ItemStack.EMPTY; + private ItemStack internal=ItemStack.EMPTY; + public ItemStack getInternal() { + return internal; + } + boolean isInfinite = false; public BowlBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { @@ -89,4 +93,12 @@ public boolean accepts(int num, ItemStack is) { return is.getItem() instanceof StewItem||is.is(Items.BOWL); } + public void setInternal(ItemStack internal) { + this.internal = internal; + this.syncData(); + } + @Override + public boolean isInfinite() { + return isInfinite; + } } diff --git a/src/main/java/com/teammoeg/caupona/blocks/foods/DishBlock.java b/src/main/java/com/teammoeg/caupona/blocks/foods/DishBlock.java index 30728a4f..d4869738 100644 --- a/src/main/java/com/teammoeg/caupona/blocks/foods/DishBlock.java +++ b/src/main/java/com/teammoeg/caupona/blocks/foods/DishBlock.java @@ -37,6 +37,7 @@ import net.minecraft.world.item.Items; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; @@ -88,7 +89,7 @@ public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState n if (!(newState.getBlock() instanceof DishBlock)) { if (worldIn.getBlockEntity(pos) instanceof DishBlockEntity dish) { - super.popResource(worldIn, pos, dish.internal); + super.popResource(worldIn, pos, dish.getInternal()); } worldIn.removeBlockEntity(pos); } @@ -101,19 +102,19 @@ public InteractionResult useWithoutItem(BlockState state, Level worldIn, BlockPo InteractionResult p = super.useWithoutItem(state, worldIn, pos, player, hit); if (p.consumesAction()) return p; - if (worldIn.getBlockEntity(pos) instanceof DishBlockEntity dish &&dish.internal != null && dish.internal.getItem() instanceof DishItem - && dish.internal.getFoodProperties(null)!=null) { - FoodProperties fp = dish.internal.getFoodProperties(player); + if (worldIn.getBlockEntity(pos) instanceof DishBlockEntity dish &&dish.getInternal() != null && dish.getInternal().getItem() instanceof DishItem + && dish.getInternal().getFoodProperties(null)!=null) { + FoodProperties fp = dish.getInternal().getFoodProperties(player); if (dish.isInfinite) { if (player.canEat(fp.canAlwaysEat())) { - player.eat(worldIn, dish.internal.copy()); + player.eat(worldIn, dish.getInternal().copy()); dish.syncData(); } } else { if (player.canEat(fp.canAlwaysEat())) { - ItemStack iout = player.eat(worldIn, dish.internal); - dish.internal = iout; - if (dish.internal.is(Items.BOWL)) { + ItemStack iout = player.eat(worldIn, dish.getInternal()); + dish.setInternal(iout); + if (dish.getInternal().is(Items.BOWL)) { worldIn.setBlockAndUpdate(pos, CPBlocks.DISH.get().defaultBlockState()); } else { worldIn.removeBlock(pos, false); @@ -131,18 +132,18 @@ public void setPlacedBy(Level pLevel, BlockPos pPos, BlockState pState, LivingEn super.setPlacedBy(pLevel, pPos, pState, pPlacer, pStack); if (pLevel.getBlockEntity(pPos) instanceof DishBlockEntity dish) { dish.setComponents(DataComponentMap.EMPTY); - dish.internal = pStack.copyWithCount(1); + dish.setInternal(pStack.copyWithCount(1)); } } - - public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter level, BlockPos pos, + @Override + public ItemStack getCloneItemStack(BlockState state, HitResult target, LevelReader level, BlockPos pos, Player player) { if (level.getBlockEntity(pos) instanceof DishBlockEntity dish) { - if (dish.internal == null) + if (dish.getInternal() == null) return ItemStack.EMPTY; - return dish.internal.copy(); + return dish.getInternal().copy(); } - return this.getCloneItemStack(state, target, level, pos, player); + return super.getCloneItemStack(state, target, level, pos, player); } @Override @@ -153,7 +154,7 @@ public boolean hasAnalogOutputSignal(BlockState pState) { @Override public int getAnalogOutputSignal(BlockState pState, Level pLevel, BlockPos pPos) { if (pLevel.getBlockEntity(pPos) instanceof DishBlockEntity dish) - if (dish.internal != null && !dish.internal.isEmpty() && dish.internal.getFoodProperties(null)!=null) + if (dish.getInternal() != null && !dish.getInternal().isEmpty() && dish.getInternal().getFoodProperties(null)!=null) return 15; return 0; diff --git a/src/main/java/com/teammoeg/caupona/blocks/foods/DishBlockEntity.java b/src/main/java/com/teammoeg/caupona/blocks/foods/DishBlockEntity.java index 5bc1fad6..99367b81 100644 --- a/src/main/java/com/teammoeg/caupona/blocks/foods/DishBlockEntity.java +++ b/src/main/java/com/teammoeg/caupona/blocks/foods/DishBlockEntity.java @@ -35,7 +35,7 @@ import net.minecraft.world.level.block.state.BlockState; public class DishBlockEntity extends CPBaseBlockEntity implements IInfinitable,IFoodContainer { - public ItemStack internal = ItemStack.EMPTY; + private ItemStack internal = ItemStack.EMPTY; boolean isInfinite = false; public DishBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { @@ -94,4 +94,16 @@ public boolean accepts(int num, ItemStack is) { return is.getItem() instanceof DishItem||is.is(Items.BOWL); } + public ItemStack getInternal() { + return internal; + } + + public void setInternal(ItemStack internal) { + this.internal = internal; + this.syncData(); + } + @Override + public boolean isInfinite() { + return isInfinite; + } } diff --git a/src/main/java/com/teammoeg/caupona/blocks/hypocaust/WolfStatueBlockEntity.java b/src/main/java/com/teammoeg/caupona/blocks/hypocaust/WolfStatueBlockEntity.java index f30e35fa..d153b99f 100644 --- a/src/main/java/com/teammoeg/caupona/blocks/hypocaust/WolfStatueBlockEntity.java +++ b/src/main/java/com/teammoeg/caupona/blocks/hypocaust/WolfStatueBlockEntity.java @@ -103,4 +103,8 @@ public void tick() { check.tick(); } + public boolean isVeryHot() { + return isVeryHot; + } + } diff --git a/src/main/java/com/teammoeg/caupona/blocks/loaf/LoafDoughBlockEntity.java b/src/main/java/com/teammoeg/caupona/blocks/loaf/LoafDoughBlockEntity.java index 9327faa8..0e213ac3 100644 --- a/src/main/java/com/teammoeg/caupona/blocks/loaf/LoafDoughBlockEntity.java +++ b/src/main/java/com/teammoeg/caupona/blocks/loaf/LoafDoughBlockEntity.java @@ -36,7 +36,7 @@ public class LoafDoughBlockEntity extends CPBaseBlockEntity { int heatValue; - int process; + public int process; LazyTickWorker ltw=new LazyTickWorker(20,()->{ if(!level.getBlockState(getBlockPos().below()).is(CPBlocks.LOAF_DOUGH)) { heatValue=(int) LoafHelper.getFireStrengh(level, getBlockPos()); diff --git a/src/main/java/com/teammoeg/caupona/blocks/pan/PanBlockEntity.java b/src/main/java/com/teammoeg/caupona/blocks/pan/PanBlockEntity.java index 44a3a6de..7e4a7a03 100644 --- a/src/main/java/com/teammoeg/caupona/blocks/pan/PanBlockEntity.java +++ b/src/main/java/com/teammoeg/caupona/blocks/pan/PanBlockEntity.java @@ -456,5 +456,8 @@ public Object getCapability(BlockCapability type, Direction d) { } return null; } - + @Override + public boolean isInfinite() { + return isInfinite; + } } diff --git a/src/main/java/com/teammoeg/caupona/blocks/pot/StewPotBlockEntity.java b/src/main/java/com/teammoeg/caupona/blocks/pot/StewPotBlockEntity.java index f6869d31..2b899b7a 100644 --- a/src/main/java/com/teammoeg/caupona/blocks/pot/StewPotBlockEntity.java +++ b/src/main/java/com/teammoeg/caupona/blocks/pot/StewPotBlockEntity.java @@ -795,5 +795,8 @@ public Object getCapability(BlockCapability cap, Direction side) { public boolean setInfinity() { return isInfinite = !isInfinite; } - + @Override + public boolean isInfinite() { + return isInfinite; + } } diff --git a/src/main/java/com/teammoeg/caupona/blocks/stove/KitchenStoveBlockEntity.java b/src/main/java/com/teammoeg/caupona/blocks/stove/KitchenStoveBlockEntity.java index 00a6dac8..f42d7876 100644 --- a/src/main/java/com/teammoeg/caupona/blocks/stove/KitchenStoveBlockEntity.java +++ b/src/main/java/com/teammoeg/caupona/blocks/stove/KitchenStoveBlockEntity.java @@ -336,5 +336,8 @@ public int getSpeed() { public boolean setInfinity() { return isInfinite = !isInfinite; } - + @Override + public boolean isInfinite() { + return isInfinite; + } } diff --git a/src/main/java/com/teammoeg/caupona/client/gui/DoliumScreen.java b/src/main/java/com/teammoeg/caupona/client/gui/DoliumScreen.java index 5817255b..716ec444 100644 --- a/src/main/java/com/teammoeg/caupona/client/gui/DoliumScreen.java +++ b/src/main/java/com/teammoeg/caupona/client/gui/DoliumScreen.java @@ -75,9 +75,8 @@ protected void renderLabels(GuiGraphics matrixStack, int x, int y) { protected void renderBg(GuiGraphics transform, float partial, int x, int y) { RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); transform.blit(TEXTURE,leftPos, topPos, 0, 0, imageWidth, imageHeight); - if (blockEntity.process > 0) { - int w = Mth.ceil(12 * (1-blockEntity.process / (float) blockEntity.processMax)); - + if (blockEntity.recipeHandler.getProcess() > 0) { + int w = Mth.ceil(12 * (1-blockEntity.recipeHandler.getProcess() / (float) blockEntity.recipeHandler.getProcessMax())); transform.blit(TEXTURE, leftPos + 117, topPos + 32, 176, 0, w, 25); } } diff --git a/src/main/java/com/teammoeg/caupona/client/renderer/BowlRenderer.java b/src/main/java/com/teammoeg/caupona/client/renderer/BowlRenderer.java index 203bb4af..c23d855f 100644 --- a/src/main/java/com/teammoeg/caupona/client/renderer/BowlRenderer.java +++ b/src/main/java/com/teammoeg/caupona/client/renderer/BowlRenderer.java @@ -64,9 +64,9 @@ public void render(BowlBlockEntity blockEntity, float partialTicks, PoseStack ma }else return; - if (blockEntity.internal == null || !(blockEntity.internal.getItem() instanceof StewItem)) + if (blockEntity.getInternal() == null || !(blockEntity.getInternal().getItem() instanceof StewItem)) return; - FluidStack fs = Utils.extractFluid(blockEntity.internal); + FluidStack fs = Utils.extractFluid(blockEntity.getInternal()); matrixStack.pushPose(); if (fs != null && !fs.isEmpty() && fs.getFluid() != null) { float y=type==2?.3125f:.28125f; diff --git a/src/main/java/com/teammoeg/caupona/client/renderer/LoafBowlRenderer.java b/src/main/java/com/teammoeg/caupona/client/renderer/LoafBowlRenderer.java index 5c67f920..58f3f36c 100644 --- a/src/main/java/com/teammoeg/caupona/client/renderer/LoafBowlRenderer.java +++ b/src/main/java/com/teammoeg/caupona/client/renderer/LoafBowlRenderer.java @@ -59,9 +59,9 @@ public void render(BowlBlockEntity blockEntity, float partialTicks, PoseStack ma if (state.getBlock() != CPBlocks.BOWL.get()) return; - if (blockEntity.internal == null || !(blockEntity.internal.getItem() instanceof StewItem)) + if (blockEntity.getInternal() == null || !(blockEntity.getInternal().getItem() instanceof StewItem)) return; - FluidStack fs = Utils.extractFluid(blockEntity.internal); + FluidStack fs = Utils.extractFluid(blockEntity.getInternal()); matrixStack.pushPose(); if (fs != null && !fs.isEmpty() && fs.getFluid() != null) { matrixStack.translate(0, .3125f, 0); diff --git a/src/main/java/com/teammoeg/caupona/compat/top/TOPRegister.java b/src/main/java/com/teammoeg/caupona/compat/top/TOPRegister.java new file mode 100644 index 00000000..31752a72 --- /dev/null +++ b/src/main/java/com/teammoeg/caupona/compat/top/TOPRegister.java @@ -0,0 +1,29 @@ +package com.teammoeg.caupona.compat.top; + +import com.teammoeg.caupona.CPMain; +import com.teammoeg.caupona.compat.top.providers.*; + +import mcjty.theoneprobe.api.ITheOneProbe; +import net.minecraft.resources.ResourceLocation; + +public class TOPRegister { + + private TOPRegister() { + } + public static Object register(ITheOneProbe top) { + top.registerProvider(new BathProvider()); + top.registerProvider(new BowlProvider()); + top.registerProvider(new DoliumProvider()); + top.registerProvider(new FumaroleProvider()); + top.registerProvider(new GravyBoatProvider()); + top.registerProvider(new LoafProvider()); + top.registerProvider(new PotProvider()); + top.registerProvider(new StoveProvider()); + top.registerProvider(new WolfProvider()); + top.registerProvider(new InfProvider()); + return null; + } + public static ResourceLocation idForBlock(String name) { + return CPMain.rl(name+"_block_info"); + } +} diff --git a/src/main/java/com/teammoeg/caupona/compat/top/providers/BathProvider.java b/src/main/java/com/teammoeg/caupona/compat/top/providers/BathProvider.java new file mode 100644 index 00000000..9e6c0ea5 --- /dev/null +++ b/src/main/java/com/teammoeg/caupona/compat/top/providers/BathProvider.java @@ -0,0 +1,32 @@ +package com.teammoeg.caupona.compat.top.providers; + +import com.teammoeg.caupona.blocks.hypocaust.BathHeatingBlockEntity; +import com.teammoeg.caupona.compat.top.TOPRegister; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; + +public class BathProvider implements IProbeInfoProvider { + + public BathProvider() { + } + + @Override + public void addProbeInfo(ProbeMode mode, IProbeInfo info, Player player, Level level, BlockState state, IProbeHitData hitResult) { + if(level.getBlockEntity(hitResult.getPos()) instanceof BathHeatingBlockEntity entity) { + info.progress(entity.getHeat(), 2, info.defaultProgressStyle().showText(false).filledColor(0xffd7454f).alternateFilledColor(0xffd7454f).backgroundColor(0xff91000a)); + } + } + + @Override + public ResourceLocation getID() { + return TOPRegister.idForBlock("bath_heat"); + } + +} diff --git a/src/main/java/com/teammoeg/caupona/compat/top/providers/BowlProvider.java b/src/main/java/com/teammoeg/caupona/compat/top/providers/BowlProvider.java new file mode 100644 index 00000000..b0193c89 --- /dev/null +++ b/src/main/java/com/teammoeg/caupona/compat/top/providers/BowlProvider.java @@ -0,0 +1,42 @@ +package com.teammoeg.caupona.compat.top.providers; + +import com.teammoeg.caupona.blocks.foods.BowlBlockEntity; +import com.teammoeg.caupona.compat.top.TOPRegister; +import com.teammoeg.caupona.util.Utils; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.neoforged.neoforge.fluids.FluidStack; + +public class BowlProvider implements IProbeInfoProvider { + + public BowlProvider() { + } + + @Override + public void addProbeInfo(ProbeMode mode, IProbeInfo info, Player player, Level level, BlockState state, IProbeHitData hitResult) { + if(level.getBlockEntity(hitResult.getPos()) instanceof BowlBlockEntity entity) { + + //info.tankSimple(1250, .getFluid()); + if(!entity.getInternal().isEmpty()) { + FluidStack extracted=Utils.extractFluid(entity.getInternal()); + if(!extracted.isEmpty()) + info.tankSimple(250,extracted, info.defaultProgressStyle().showText(false).height(16).width(16)); + } + + + } + } + + @Override + public ResourceLocation getID() { + return TOPRegister.idForBlock("bowl"); + } + +} diff --git a/src/main/java/com/teammoeg/caupona/compat/top/providers/DoliumProvider.java b/src/main/java/com/teammoeg/caupona/compat/top/providers/DoliumProvider.java new file mode 100644 index 00000000..32b0de78 --- /dev/null +++ b/src/main/java/com/teammoeg/caupona/compat/top/providers/DoliumProvider.java @@ -0,0 +1,66 @@ +package com.teammoeg.caupona.compat.top.providers; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import com.teammoeg.caupona.blocks.dolium.CounterDoliumBlockEntity; +import com.teammoeg.caupona.compat.top.TOPRegister; +import com.teammoeg.caupona.data.recipes.DoliumRecipe; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.neoforged.neoforge.items.ItemStackHandler; + +public class DoliumProvider implements IProbeInfoProvider { + + @Override + public void addProbeInfo(ProbeMode mode, IProbeInfo info, Player player, Level level, BlockState state, IProbeHitData hitResult) { + if(level.getBlockEntity(hitResult.getPos()) instanceof CounterDoliumBlockEntity entity) { + //info.tankSimple(1250, .getFluid()); + info.tankHandler(entity.tank); + if(player.isShiftKeyDown()) { + ItemStackHandler inventory=entity.getInv(); + List inputs=new ArrayList<>(); + for(int i=0;i0) { + + + if(player.isShiftKeyDown()) + if(entity.recipeHandler.getLastRecipe()!=null) { + level.getRecipeManager().byKey(entity.recipeHandler.getLastRecipe()).flatMap(t->t.value() instanceof DoliumRecipe?Optional.of((DoliumRecipe)t.value()):Optional.empty()) + .ifPresent(r->{ + IProbeInfo layout=info.horizontal(info.defaultLayoutStyle().borderColor(0x88ffffff).spacing(0)); + if(!r.output.isEmpty()) + layout.item(r.output); + }); + } + } + + } + } + + + @Override + public ResourceLocation getID() { + return TOPRegister.idForBlock("counter_dolium"); + } + +} diff --git a/src/main/java/com/teammoeg/caupona/compat/top/providers/FumaroleProvider.java b/src/main/java/com/teammoeg/caupona/compat/top/providers/FumaroleProvider.java new file mode 100644 index 00000000..20356abd --- /dev/null +++ b/src/main/java/com/teammoeg/caupona/compat/top/providers/FumaroleProvider.java @@ -0,0 +1,32 @@ +package com.teammoeg.caupona.compat.top.providers; + +import com.teammoeg.caupona.blocks.fumarole.FumaroleVentBlock; +import com.teammoeg.caupona.compat.top.TOPRegister; +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; + +public class FumaroleProvider implements IProbeInfoProvider { + + public FumaroleProvider() { + } + + @Override + public void addProbeInfo(ProbeMode mode, IProbeInfo info, Player player, Level level, BlockState state, IProbeHitData hitResult) { + if(state.hasProperty(FumaroleVentBlock.HEAT)) { + int heat=state.getValue(FumaroleVentBlock.HEAT); + info.progress(heat, 2, info.defaultProgressStyle().showText(false).filledColor(0xffd7454f).alternateFilledColor(0xffd7454f).backgroundColor(0xff91000a)); + } + } + + @Override + public ResourceLocation getID() { + return TOPRegister.idForBlock("fumarole_heat"); + } + +} diff --git a/src/main/java/com/teammoeg/caupona/compat/top/providers/GravyBoatProvider.java b/src/main/java/com/teammoeg/caupona/compat/top/providers/GravyBoatProvider.java new file mode 100644 index 00000000..bb4dc1f5 --- /dev/null +++ b/src/main/java/com/teammoeg/caupona/compat/top/providers/GravyBoatProvider.java @@ -0,0 +1,33 @@ +package com.teammoeg.caupona.compat.top.providers; + +import com.teammoeg.caupona.blocks.pan.GravyBoatBlock; +import com.teammoeg.caupona.compat.top.TOPRegister; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; + +public class GravyBoatProvider implements IProbeInfoProvider { + + public GravyBoatProvider() { + } + + @Override + public void addProbeInfo(ProbeMode mode, IProbeInfo info, Player player, Level level, BlockState state, IProbeHitData hitResult) { + if(state.hasProperty(GravyBoatBlock.LEVEL)) { + int damage=state.getValue(GravyBoatBlock.LEVEL); + info.progress(5-damage, 5, info.defaultProgressStyle().filledColor(0xfff9ff00).alternateFilledColor(0xfff9ff00)); + } + } + + @Override + public ResourceLocation getID() { + return TOPRegister.idForBlock("gravt_boat"); + } + +} diff --git a/src/main/java/com/teammoeg/caupona/compat/top/providers/InfProvider.java b/src/main/java/com/teammoeg/caupona/compat/top/providers/InfProvider.java new file mode 100644 index 00000000..65c0a5ab --- /dev/null +++ b/src/main/java/com/teammoeg/caupona/compat/top/providers/InfProvider.java @@ -0,0 +1,34 @@ +package com.teammoeg.caupona.compat.top.providers; + +import com.teammoeg.caupona.CPItems; +import com.teammoeg.caupona.compat.top.TOPRegister; +import com.teammoeg.caupona.util.IInfinitable; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; + +public class InfProvider implements IProbeInfoProvider { + + @Override + public void addProbeInfo(ProbeMode mode, IProbeInfo info, Player player, Level level, BlockState state, IProbeHitData hitResult) { + if(level.getBlockEntity(hitResult.getPos()) instanceof IInfinitable entity) { + if(player.isShiftKeyDown()&&entity.isInfinite()) { + info.item(new ItemStack(CPItems.chronoconis)); + } + } + } + + + @Override + public ResourceLocation getID() { + return TOPRegister.idForBlock("kitchen_stove"); + } + +} diff --git a/src/main/java/com/teammoeg/caupona/compat/top/providers/LoafProvider.java b/src/main/java/com/teammoeg/caupona/compat/top/providers/LoafProvider.java new file mode 100644 index 00000000..01795c81 --- /dev/null +++ b/src/main/java/com/teammoeg/caupona/compat/top/providers/LoafProvider.java @@ -0,0 +1,29 @@ +package com.teammoeg.caupona.compat.top.providers; + +import com.teammoeg.caupona.CPConfig; +import com.teammoeg.caupona.blocks.loaf.LoafDoughBlockEntity; +import com.teammoeg.caupona.compat.top.TOPRegister; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; + +public class LoafProvider implements IProbeInfoProvider { + + @Override + public void addProbeInfo(ProbeMode mode, IProbeInfo info, Player player, Level level, BlockState state, IProbeHitData hitResult) { + if(level.getBlockEntity(hitResult.getPos()) instanceof LoafDoughBlockEntity entity) { + info.progress(entity.process, CPConfig.COMMON.loafCooking.get(),info.defaultProgressStyle().showText(false)); + } + } + @Override + public ResourceLocation getID() { + return TOPRegister.idForBlock("loaf_dough"); + } + +} diff --git a/src/main/java/com/teammoeg/caupona/compat/top/providers/PotProvider.java b/src/main/java/com/teammoeg/caupona/compat/top/providers/PotProvider.java new file mode 100644 index 00000000..b1f796e3 --- /dev/null +++ b/src/main/java/com/teammoeg/caupona/compat/top/providers/PotProvider.java @@ -0,0 +1,61 @@ +package com.teammoeg.caupona.compat.top.providers; + +import java.util.ArrayList; +import java.util.List; +import com.teammoeg.caupona.blocks.pot.StewPotBlockEntity; +import com.teammoeg.caupona.compat.top.TOPRegister; +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.neoforged.neoforge.items.ItemStackHandler; + +public class PotProvider implements IProbeInfoProvider { + + @Override + public void addProbeInfo(ProbeMode mode, IProbeInfo info, Player player, Level level, BlockState state, IProbeHitData hitResult) { + if(level.getBlockEntity(hitResult.getPos()) instanceof StewPotBlockEntity entity) { + //info.tankSimple(1250, .getFluid()); + info.tankHandler(entity.getTank()); + if(player.isShiftKeyDown()) { + ItemStackHandler inventory=entity.getInv(); + List inputs=new ArrayList<>(); + for(int i=0;i0) { + + + if(player.isShiftKeyDown()){ + if(entity.output!=null) { + info.tankSimple(entity.output.getAmount(),entity.output, info.defaultProgressStyle().showText(false).height(16).width(16)); + } + } + } + + } + } + + + @Override + public ResourceLocation getID() { + return TOPRegister.idForBlock("stew_pot"); + } + +} diff --git a/src/main/java/com/teammoeg/caupona/compat/top/providers/StoveProvider.java b/src/main/java/com/teammoeg/caupona/compat/top/providers/StoveProvider.java new file mode 100644 index 00000000..01800916 --- /dev/null +++ b/src/main/java/com/teammoeg/caupona/compat/top/providers/StoveProvider.java @@ -0,0 +1,48 @@ +package com.teammoeg.caupona.compat.top.providers; + +import java.util.ArrayList; +import java.util.List; +import com.teammoeg.caupona.blocks.stove.KitchenStoveBlockEntity; +import com.teammoeg.caupona.compat.top.TOPRegister; +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.Container; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; + +public class StoveProvider implements IProbeInfoProvider { + + @Override + public void addProbeInfo(ProbeMode mode, IProbeInfo info, Player player, Level level, BlockState state, IProbeHitData hitResult) { + if(level.getBlockEntity(hitResult.getPos()) instanceof KitchenStoveBlockEntity entity) { + //info.tankSimple(1250, .getFluid()); + if(player.isShiftKeyDown()) { + Container inventory=entity; + List inputs=new ArrayList<>(); + for(int i=0;i> recipes; public static DeferredHolder,RecipeType>> TYPE; public static DeferredHolder,RecipeSerializer> SERIALIZER; @@ -263,4 +263,9 @@ public void write(FriendlyByteBuf data) { } */ + @Override + public int getTime() { + return time; + } + } diff --git a/src/main/java/com/teammoeg/caupona/data/recipes/TimedRecipe.java b/src/main/java/com/teammoeg/caupona/data/recipes/TimedRecipe.java new file mode 100644 index 00000000..4e6a97e7 --- /dev/null +++ b/src/main/java/com/teammoeg/caupona/data/recipes/TimedRecipe.java @@ -0,0 +1,5 @@ +package com.teammoeg.caupona.data.recipes; + +public interface TimedRecipe { + int getTime(); +} diff --git a/src/main/java/com/teammoeg/caupona/network/CPBaseBlockEntity.java b/src/main/java/com/teammoeg/caupona/network/CPBaseBlockEntity.java index 848a25d4..d0372cf6 100644 --- a/src/main/java/com/teammoeg/caupona/network/CPBaseBlockEntity.java +++ b/src/main/java/com/teammoeg/caupona/network/CPBaseBlockEntity.java @@ -45,7 +45,9 @@ public void sendMessage(short type, int data) { } public void syncData() { - this.level.sendBlockUpdated(this.worldPosition, this.getBlockState(), this.getBlockState(), 3); + if(this.level!=null) { + this.level.sendBlockUpdated(this.worldPosition, this.getBlockState(), this.getBlockState(), 3); + } this.setChanged(); } diff --git a/src/main/java/com/teammoeg/caupona/util/IInfinitable.java b/src/main/java/com/teammoeg/caupona/util/IInfinitable.java index cbd5c693..f682d817 100644 --- a/src/main/java/com/teammoeg/caupona/util/IInfinitable.java +++ b/src/main/java/com/teammoeg/caupona/util/IInfinitable.java @@ -23,4 +23,9 @@ public interface IInfinitable { boolean setInfinity(); + default boolean isInfinite() { + setInfinity(); + return setInfinity(); + + }; } diff --git a/src/main/java/com/teammoeg/caupona/util/RecipeHandler.java b/src/main/java/com/teammoeg/caupona/util/RecipeHandler.java new file mode 100644 index 00000000..6cb0998b --- /dev/null +++ b/src/main/java/com/teammoeg/caupona/util/RecipeHandler.java @@ -0,0 +1,88 @@ +package com.teammoeg.caupona.util; + +import com.teammoeg.caupona.data.recipes.TimedRecipe; + +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeHolder; + +public class RecipeHandler&TimedRecipe>{ + private int process; + private int processMax; + private ResourceLocation lastRecipe; + private boolean recipeTested=false; + private Runnable doRecipe; + public ResourceLocation getLastRecipe() { + return lastRecipe; + } + public RecipeHandler(Runnable doRecipe) { + this.doRecipe=doRecipe; + } + public void onContainerChanged() { + //System.out.println("revalidate needed"); + recipeTested=false; + } + public boolean shouldTestRecipe() { + return !recipeTested; + } + public void setRecipe(RecipeHolder recipe) { + //System.out.println("revalidate return "+recipe); + if (recipe!= null) { + if(!recipe.id().equals(lastRecipe)) { + process=processMax=recipe.value().getTime(); + lastRecipe=recipe.id(); + } + }else { + process=processMax=0; + lastRecipe=null; + } + recipeTested=true; + } + public boolean tickProcess(int num) { + if (process > 0) { + process-=num; + if(process<=0) { + doRecipe.run(); + process=processMax=0; + lastRecipe=null; + recipeTested=false; + } + return true; + } + return false; + } + public void resetProgress() { + process=processMax; + } + public void readCustomNBT(CompoundTag nbt, boolean isClient) { + process=nbt.getInt("process"); + processMax=nbt.getInt("processMax"); + if (!isClient) { + if(nbt.contains("lastRecipe")) + lastRecipe=ResourceLocation.parse(nbt.getString("lastRecipe")); + else + lastRecipe=null; + } + + } + public void writeCustomNBT(CompoundTag nbt, boolean isClient) { + nbt.putInt("process",process); + nbt.putInt("processMax",processMax); + if (!isClient) { + if(lastRecipe!=null) + nbt.putString("lastRecipe", lastRecipe.toString()); + } + + } + public int getProcess() { + return process; + } + public int getProcessMax() { + return processMax; + } + public int getFinishedProgress() { + return processMax-process; + } + +}