Skip to content

Commit

Permalink
update neoforge to release
Browse files Browse the repository at this point in the history
-  add jei
  • Loading branch information
Cheaterpaul committed Jun 15, 2024
1 parent 84e8c87 commit d482fbd
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 51 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ org.gradle.debug=false
# forge
minecraft_version=1.20.6
minecraft_version_range=[1.20.6,1.21)
forge_version=20.6.56-beta
forge_version_range=[20.6.56-beta,)
forge_version=20.6.115
forge_version_range=[20.6.115,)
loader_version_range=[1,)
parchment_minecraft_version=1.20.6
parchment_mappings_version=2024.05.01
Expand Down Expand Up @@ -36,9 +36,9 @@ type="test"
classification="test"

#jei setting
include_jei=false
jei_mc_version=1.20.4
jei_version=17.3.0.48
include_jei=true
jei_mc_version=1.20.6
jei_version=18.0.0.62

#guideapi setting
include_guideapi=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public static void serverTick(@NotNull Level level, BlockPos pos, BlockState sta
if (blockEntity.isBurning() || !itemstackFuel.isEmpty() && !blockEntity.items.get(0).isEmpty() && !blockEntity.items.get(1).isEmpty()) {
RecipeHolder<AlchemicalCauldronRecipe> cauldronRecipe = blockEntity.quickCheck.getRecipeFor(blockEntity, level).orElse(null);

if (cauldronRecipe != null && !blockEntity.isBurning() && ((AbstractFurnaceBlockEntityAccessor) blockEntity).invoke_canBurn(level.registryAccess(), cauldronRecipe, blockEntity.items, blockEntity.getMaxStackSize()) && blockEntity.canPlayerCook(cauldronRecipe.value())) {
if (cauldronRecipe != null && !blockEntity.isBurning() && ((AbstractFurnaceBlockEntityAccessor) blockEntity).invoke_canBurn(level.registryAccess(), cauldronRecipe, blockEntity.items, blockEntity.getMaxStackSize(), blockEntity) && blockEntity.canPlayerCook(cauldronRecipe.value())) {
blockEntity.dataAccess.set(0, blockEntity.getBurnDuration(itemstackFuel)); //Set burn time
blockEntity.dataAccess.set(1, blockEntity.dataAccess.get(0));
if (blockEntity.isBurning()) {
Expand All @@ -244,7 +244,7 @@ public static void serverTick(@NotNull Level level, BlockPos pos, BlockState sta
}
}

if (cauldronRecipe != null && blockEntity.isBurning() && ((AbstractFurnaceBlockEntityAccessor) blockEntity).invoke_canBurn(level.registryAccess(), cauldronRecipe, blockEntity.items, blockEntity.getMaxStackSize()) && blockEntity.canPlayerCook(cauldronRecipe.value())) {
if (cauldronRecipe != null && blockEntity.isBurning() && ((AbstractFurnaceBlockEntityAccessor) blockEntity).invoke_canBurn(level.registryAccess(), cauldronRecipe, blockEntity.items, blockEntity.getMaxStackSize(), blockEntity) && blockEntity.canPlayerCook(cauldronRecipe.value())) {
blockEntity.dataAccess.set(2, blockEntity.dataAccess.get(2) + 1); //Increase cook time
if (blockEntity.dataAccess.get(2) == blockEntity.dataAccess.get(3)) { //If finished
blockEntity.dataAccess.set(2, 0);
Expand Down Expand Up @@ -303,7 +303,7 @@ private boolean canPlayerCook(@NotNull AlchemicalCauldronRecipe recipe) {
* copy of AbstractFurnaceTileEntity#finishCooking(IRecipe) with modification
*/
private void finishCooking(RegistryAccess access, @Nullable RecipeHolder<AlchemicalCauldronRecipe> recipe) {
if (recipe != null && ((AbstractFurnaceBlockEntityAccessor) this).invoke_canBurn(access, recipe, items, getMaxStackSize()) && canPlayerCook(recipe.value())) {
if (recipe != null && ((AbstractFurnaceBlockEntityAccessor) this).invoke_canBurn(access, recipe, items, getMaxStackSize(), this) && canPlayerCook(recipe.value())) {
ItemStack itemstackfluid = this.items.get(0);
ItemStack itemstackingredient = this.items.get(1);
ItemStack itemstack1result = recipe.value().getResultItem(access);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ private boolean capturePreconditions(@Nullable IFaction<?> faction, @NotNull BiC
}
VampirismVillageEvent.InitiateCapture event = new VampirismVillageEvent.InitiateCapture(this, faction);
NeoForge.EVENT_BUS.post(event);
if (event.getResult().equals(Event.Result.DENY)) {
if (event.isCaptureDisallowed()) {
if (event.getMessage() != null) {
feedback.accept(Component.translatable(event.getMessage()), true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public VoxelShape getShape(@NotNull BlockState state, BlockGetter worldIn, Block
}

@Override
public boolean isBed(@NotNull BlockState state, BlockGetter world, BlockPos pos, Entity player) {
public boolean isBed(@NotNull BlockState state, BlockGetter world, BlockPos pos, LivingEntity sleeper) {
return !state.getValue(CLOSED) || state.getValue(BedBlock.OCCUPIED);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/teamlapen/vampirism/blocks/TentBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public void fallOn(@NotNull Level worldIn, @NotNull BlockState state, @NotNull B
}

@Override
public boolean isBed(BlockState state, BlockGetter world, BlockPos pos, @Nullable Entity player) {
public boolean isBed(BlockState state, BlockGetter level, BlockPos pos, LivingEntity sleeper) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import net.neoforged.bus.api.EventPriority;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.common.util.TriState;
import net.neoforged.neoforge.event.entity.EntityEvent;
import net.neoforged.neoforge.event.entity.EntityMountEvent;
import net.neoforged.neoforge.event.entity.living.*;
Expand Down Expand Up @@ -224,9 +225,9 @@ public void onBreakSpeed(PlayerEvent.@NotNull BreakSpeed event) {
}

@SubscribeEvent
public void onItemPickupPre(@NotNull EntityItemPickupEvent event) {
if (VampirismPlayerAttributes.get(event.getEntity()).getVampSpecial().isDBNO) {
event.setCanceled(true);
public void onItemPickupPre(@NotNull ItemEntityPickupEvent.Pre event) {
if (VampirismPlayerAttributes.get(event.getPlayer()).getVampSpecial().isDBNO) {
event.setCanPickup(TriState.FALSE);
}
}

Expand Down Expand Up @@ -375,7 +376,7 @@ public void onPlayerInteract(PlayerInteractEvent.@NotNull RightClickBlock event)
}
}
if ((bloodBottle || convert) && block instanceof BloodContainerBlock) {
event.setUseBlock(Event.Result.ALLOW);
event.setUseBlock(TriState.TRUE);
}
if (convert) {
//Dangerous, but only solution I found so far
Expand Down Expand Up @@ -432,12 +433,25 @@ public void onPlayerName(PlayerEvent.@NotNull NameFormat event) {
}

@SubscribeEvent
public void sleepTimeCheck(@NotNull SleepingTimeCheckEvent event) {
if (Helper.isVampire(event.getEntity())) {
event.getSleepingLocation().ifPresent((blockPos -> event.setResult(event.getEntity().level().getBlockState(blockPos).getBlock() instanceof CoffinBlock ? event.getEntity().level().isDay() ? Event.Result.ALLOW : Event.Result.DENY : event.getResult())));
public void sleepTimeCheck(@NotNull CanPlayerSleepEvent event) {
if (Helper.isVampire(event.getEntity()) && event.getState().getBlock() instanceof CoffinBlock) {
if (event.getLevel().isNight() && event.getProblem() == null) {
event.setProblem(Player.BedSleepingProblem.NOT_POSSIBLE_NOW);
} else if (event.getLevel().isDay() && event.getProblem() == Player.BedSleepingProblem.NOT_POSSIBLE_NOW) {
event.setProblem(null);
}
}
if (Helper.isHunter(event.getEntity())) {
event.getSleepingLocation().ifPresent((blockPos -> event.setResult(event.getEntity().getCommandSenderWorld().getBlockState(blockPos).getBlock() instanceof TentBlock ? !event.getEntity().getCommandSenderWorld().isDay() ? Event.Result.ALLOW : Event.Result.DENY : event.getResult())));
}

@SubscribeEvent
public void canContinueToSleep(CanContinueSleepingEvent event) {
if (Helper.isVampire(event.getEntity()) && event.getEntity().getSleepingPos().map(s -> event.getEntity().level().getBlockState(s)).map(s -> s.getBlock() instanceof CoffinBlock).orElse(false)) {
boolean day = event.getEntity().level().isDay();
if (day && event.getProblem() == Player.BedSleepingProblem.NOT_POSSIBLE_NOW) {
event.setContinueSleeping(true);
} else if (!day) {
event.setContinueSleeping(false);
}
}
}

Expand Down Expand Up @@ -502,8 +516,7 @@ public void onPlayerAttackCritical(@NotNull CriticalHitEvent event) {
if (!stack.isEmpty() && stack.getItem() instanceof IFactionSlayerItem item) {
IFaction<?> faction = VampirismAPI.factionRegistry().getFaction(event.getTarget());
if (faction != null && faction.equals(item.getSlayedFaction())) {
event.setResult(Event.Result.ALLOW);
event.setDamageModifier(event.getDamageModifier() + (event.getOldDamageModifier() * (item.getDamageMultiplierForFaction(stack) - 1)));
event.setDamageMultiplier(event.getDamageMultiplier() + (event.getVanillaMultiplier() * (item.getDamageMultiplierForFaction(stack) - 1)));
}
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/de/teamlapen/vampirism/items/BloodBottleItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,11 @@ public boolean doesSneakBypassUse(ItemStack stack, @NotNull LevelReader world, @

@Override
public void generateCreativeTab(CreativeModeTab.@NotNull ItemDisplayParameters parameters, CreativeModeTab.Output output) {
for (int i = 0; i < BloodBottleItem.AMOUNT; i++) {
for (int i = 0; i <= BloodBottleItem.AMOUNT; i++) {
ItemStack stack = getDefaultInstance();
stack.set(ModDataComponents.BOTTLE_BLOOD, new BottleBlood(i));
output.accept(stack, CreativeModeTab.TabVisibility.SEARCH_TAB_ONLY);
output.accept(stack, i == 0 || i == BloodBottleItem.AMOUNT ? CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS : CreativeModeTab.TabVisibility.SEARCH_TAB_ONLY);
}
ItemStack stack0 = getDefaultInstance();
stack0.set(ModDataComponents.BOTTLE_BLOOD, BottleBlood.EMPTY);
output.accept(stack0, CreativeModeTab.TabVisibility.PARENT_TAB_ONLY);
ItemStack stack9 = getDefaultInstance();
stack9.set(ModDataComponents.BOTTLE_BLOOD, new BottleBlood(BloodBottleItem.AMOUNT));
output.accept(stack9, CreativeModeTab.TabVisibility.PARENT_TAB_ONLY);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public interface AbstractFurnaceBlockEntityAccessor {

@Invoker("canBurn")
boolean invoke_canBurn(RegistryAccess registryAccess, @Nullable RecipeHolder<?> recipe, NonNullList<ItemStack> availableItems, int maxStackSize);
boolean invoke_canBurn(RegistryAccess registryAccess, @Nullable RecipeHolder<?> recipe, NonNullList<ItemStack> availableItems, int maxStackSize, AbstractFurnaceBlockEntity furnace);

@Invoker("getTotalCookTime")
static int getTotalCookTime(Level pLevel, AbstractFurnaceBlockEntity pBlockEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.teamlapen.vampirism.REFERENCE;
import de.teamlapen.vampirism.api.entity.player.skills.ISkill;
import de.teamlapen.vampirism.core.ModBlocks;
import de.teamlapen.vampirism.items.component.OilContent;
import de.teamlapen.vampirism.recipes.AlchemyTableRecipe;
import de.teamlapen.vampirism.util.OilUtils;
import mezz.jei.api.constants.VanillaTypes;
Expand Down Expand Up @@ -90,7 +91,7 @@ public void draw(@NotNull RecipeHolder<AlchemyTableRecipe> holder, IRecipeSlotsV
this.blazeHeat.draw(graphics, 33 - 9 - 2, 60 - 10 - 2);
this.arrow.draw(graphics, 73 - 9 - 2, 57 - 10 - 2);

int color = OilUtils.getOil(RecipeUtil.getResultItem(recipe)).getColor();
int color = OilContent.getOil(RecipeUtil.getResultItem(recipe)).value().getColor();
graphics.setColor(((color >> 16) & 0xFF) / 255f, ((color >> 8) & 0xFF) / 255f, ((color) & 0xFF) / 255f, 1F);
this.pool.draw(graphics, 104 - 9 - 2, 36 - 10 - 2);
graphics.setColor(1, 1, 1, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@


import de.teamlapen.vampirism.api.items.ExtendedPotionMix;
import net.minecraft.core.Holder;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.item.alchemy.PotionContents;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -21,17 +22,17 @@ public class JEIPotionMix {
List<ItemStack> in1 = Arrays.stream(mix.reagent1.get().getItems()).map(ItemStack::copy).peek(s -> s.setCount(mix.reagent1Count)).filter(s -> !s.isEmpty()).collect(Collectors.toList());
List<ItemStack> in2 = Arrays.stream(mix.reagent2.get().getItems()).map(ItemStack::copy).peek(s -> s.setCount(mix.reagent2Count)).filter(s -> !s.isEmpty()).collect(Collectors.toList());
List<JEIPotionMix> recipes = new ArrayList<>(3);
recipes.add(build(mix, Items.POTION, mix.input.get(), mix.output.get(), in1, in2));
if (mix.output.get().getEffects().stream().noneMatch(s -> s.getEffect().getCategory() != MobEffectCategory.HARMFUL)) {
recipes.add(build(mix, Items.LINGERING_POTION, mix.input.get(), mix.output.get(), in1, in2));
recipes.add(build(mix, Items.SPLASH_POTION, mix.input.get(), mix.output.get(), in1, in2));
recipes.add(build(mix, Items.POTION, mix.input, mix.output, in1, in2));
if (mix.output.value().getEffects().stream().noneMatch(s -> s.getEffect().value().getCategory() != MobEffectCategory.HARMFUL)) {
recipes.add(build(mix, Items.LINGERING_POTION, mix.input, mix.output, in1, in2));
recipes.add(build(mix, Items.SPLASH_POTION, mix.input, mix.output, in1, in2));
}
return recipes;
}

private static @NotNull JEIPotionMix build(ExtendedPotionMix mix, Item base, @NotNull Potion in, @NotNull Potion out, List<ItemStack> in1, List<ItemStack> in2) {
ItemStack potionIn = PotionUtils.setPotion(new ItemStack(base), in);
ItemStack potionOut = PotionUtils.setPotion(new ItemStack(base), out);
private static @NotNull JEIPotionMix build(ExtendedPotionMix mix, Item base, @NotNull Holder<Potion> in, @NotNull Holder<Potion> out, List<ItemStack> in1, List<ItemStack> in2) {
ItemStack potionIn = PotionContents.createItemStack(base, in);
ItemStack potionOut = PotionContents.createItemStack(base, out);
return new JEIPotionMix(mix, potionIn, in1, in2, potionOut);
}

Expand Down
Loading

0 comments on commit d482fbd

Please sign in to comment.