Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into feature/mother_generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Oct 28, 2023
2 parents 7529338 + 2e9f4dc commit 829fdf6
Show file tree
Hide file tree
Showing 29 changed files with 282 additions and 133 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ The following labeling scheme is used:
- *discussion*: Looking for feedback
- *enhancement*: Any minor tweak that can be introduced in minor releases
- *feature*: Any change that takes more time to implement and test
- *accepted*: Any feature/enhancement that is planned to be implemented eventually
- *1.12-1.***: Affecting only a specific MC version
- *v1.8-v1.**: Bug affecting or enhancement targeting a specific Vamprism release branch
- *v1.8-v1.**: Bug affecting or enhancement targeting a specific Vampirism release branch
- *latest*: Bug affecting or enhancement targeting the latest (potentially unreleased) Vampirism branch


Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx3G
# forge
minecraft_version=1.20.1
minecraft_version_range=[1.20.1,1.21)
forge_version=47.1.0
forge_version=47.2.0
forge_version_range=[47,)
loader_version_range=[47,)
mappings_channel=parchment
Expand Down Expand Up @@ -38,5 +38,5 @@ include_terrablender=true
#Dependencies/Optional Libraries
jei_mc_version=1.20.1
jei_version=15.0.0.12
guideapi_version=1.20.1-2.2.6-alpha+20230617-1850
guideapi_version=1.20.1-2.2.6
terrablender_version=1.20.1-3.0.0.164
25 changes: 25 additions & 0 deletions src/lib/java/de/teamlapen/lib/lib/util/RegisterHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package de.teamlapen.lib.lib.util;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.*;

public class RegisterHelper {

public static <T extends ItemLike> T compostable(T item, float chance) {
ComposterBlock.COMPOSTABLES.put(item, chance);
return item;
}

public static <T extends Block> T flammable(T block, int encouragement, int flammability) {
FireBlock fireblock = (FireBlock) Blocks.FIRE;
fireblock.setFlammable(block, encouragement, flammability);
return block;
}

public static <T extends Block> T potted(T potBlock, ResourceLocation plant) {
FlowerPotBlock pot = (FlowerPotBlock) Blocks.FLOWER_POT;
pot.addPlant(plant, () -> potBlock);
return potBlock;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void render(@NotNull ForgeGui gui, @NotNull GuiGraphics graphics, float p
text = String.valueOf(handler.getCurrentLevel());
}
int x = (this.mc.getWindow().getGuiScaledWidth() - this.mc.font.width(text)) / 2 + VampirismConfig.CLIENT.guiLevelOffsetX.get();
int y = this.mc.getWindow().getGuiScaledHeight() - VampirismConfig.CLIENT.guiLevelOffsetY.get() - 39;
int y = this.mc.getWindow().getGuiScaledHeight() - VampirismConfig.CLIENT.guiLevelOffsetY.get();
graphics.drawString(this.mc.font, text, x + 1, y, 0, false);
graphics.drawString(this.mc.font, text, x - 1, y, 0, false);
graphics.drawString(this.mc.font, text, x, y + 1, 0, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.collect.ImmutableList;
import de.teamlapen.vampirism.client.core.ModEntitiesRender;
import de.teamlapen.vampirism.util.MixinHooks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.geom.ModelPart;
Expand All @@ -10,10 +11,14 @@
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.NotNull;

import static net.minecraft.client.renderer.entity.LivingEntityRenderer.isEntityUpsideDown;

@OnlyIn(Dist.CLIENT)
public class CloakModel extends VampirismArmorModel {

Expand All @@ -29,11 +34,12 @@ public class CloakModel extends VampirismArmorModel {

private static CloakModel cloakItemModel;

public static CloakModel getAdjustedCloak(HumanoidModel<?> wearerModel) {
public static CloakModel getAdjustedCloak(HumanoidModel<?> wearerModel, LivingEntity entity) {
if (cloakItemModel == null) {
cloakItemModel = new CloakModel(Minecraft.getInstance().getEntityModels().bakeLayer(ModEntitiesRender.CLOAK));
}
cloakItemModel.copyFromHumanoid(wearerModel);
cloakItemModel.setupAnimation(entity);
return cloakItemModel;
}

Expand Down Expand Up @@ -74,47 +80,91 @@ public CloakModel(@NotNull ModelPart part) {
shoulderright = part.getChild(SHOULDER_RIGHT);
}

// @Override
// public void setupAnim(@NotNull LivingEntity entity, float f, float f1, float ageInTicks, float netHeadYaw, float headPitch) {
// super.setupAnim(entity, f, f1, ageInTicks, netHeadYaw, headPitch);
// //Isn't use afaik
//
//
// boolean flag = entity != null && entity.getFallFlyingTicks() > 4;
//
// float f6 = 1.0F;
// if (flag) {
// f6 = (float) (entity.getDeltaMovement().x * entity.getDeltaMovement().x + entity.getDeltaMovement().y * entity.getDeltaMovement().y
// + entity.getDeltaMovement().z * entity.getDeltaMovement().z);
// f6 = f6 / 0.2F;
// f6 = f6 * f6 * f6;
// }
//
// if (f6 < 1.0F) {
// f6 = 1.0F;
// }
//
// float rotation = Mth.cos(f * 0.6662F) * 1.4F * f1 / f6;
// if (rotation < 0.0F)
// rotation *= -1;
// this.cloakback.xRot = 0.0872665F + (rotation / 3);
// this.leftlong.xRot = 0.0872665F + (rotation / 3);
// this.rightlong.xRot = 0.0872665F + (rotation / 3);
// this.leftmedium.xRot = 0.0872665F + (rotation / 3);
// this.rightmedium.xRot = 0.0872665F + (rotation / 3);
// this.rightshort.xRot = 0.0872665F + (rotation / 3);
// this.leftshort.xRot = 0.0872665F + (rotation / 3);
//
// if (this.crouching) {
// this.cloakback.xRot += 0.5F;
// this.leftlong.xRot += 0.5F;
// this.rightlong.xRot += 0.5F;
// this.leftmedium.xRot += 0.5F;
// this.rightmedium.xRot += 0.5F;
// this.leftshort.xRot += 0.5F;
// this.rightshort.xRot += 0.5F;
// }
// }
private void setupAnimation(LivingEntity entity) {
boolean shouldSit = entity.isPassenger() && (entity.getVehicle() != null && entity.getVehicle().shouldRiderSit());

float f = Mth.rotLerp(MixinHooks.armorLayerPartialTicks, entity.yBodyRotO, entity.yBodyRot);
float f1 = Mth.rotLerp(MixinHooks.armorLayerPartialTicks, entity.yHeadRotO, entity.yHeadRot);
float f2 = f1 - f;

float f6 = Mth.lerp(MixinHooks.armorLayerPartialTicks, entity.xRotO, entity.getXRot());

if (shouldSit && entity.getVehicle() instanceof LivingEntity livingentity) {
f = Mth.rotLerp(MixinHooks.armorLayerPartialTicks, livingentity.yBodyRotO, livingentity.yBodyRot);
f2 = f1 - f;
float f3 = Mth.wrapDegrees(f2);
if (f3 < -85.0F) {
f3 = -85.0F;
}

if (f3 >= 85.0F) {
f3 = 85.0F;
}

f = f1 - f3;
if (f3 * f3 > 2500.0F) {
f += f3 * 0.2F;
}

f2 = f1 - f;
}

if (isEntityUpsideDown(entity)) {
f6 *= -1.0F;
f2 *= -1.0F;
}

float f8 = 0.0F;
float f5 = 0.0F;
if (!shouldSit && entity.isAlive()) {
f8 = entity.walkAnimation.speed(MixinHooks.armorLayerPartialTicks);
f5 = entity.walkAnimation.position(MixinHooks.armorLayerPartialTicks);
if (entity.isBaby()) {
f5 *= 3.0F;
}

if (f8 > 1.0F) {
f8 = 1.0F;
}
}
cloakItemModel.setupAnim(entity, f5, f8,entity.tickCount + MixinHooks.armorLayerPartialTicks, f2, f6);
}

public void setupAnim(@NotNull LivingEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
boolean flag = entity != null && entity.getFallFlyingTicks() > 4;

float f6 = 1.0F;
if (flag) {
f6 = (float) (entity.getDeltaMovement().x * entity.getDeltaMovement().x + entity.getDeltaMovement().y * entity.getDeltaMovement().y + entity.getDeltaMovement().z * entity.getDeltaMovement().z);
f6 = f6 / 0.2F;
f6 = f6 * f6 * f6;
}

if (f6 < 1.0F) {
f6 = 1.0F;
}

float rotation = Mth.cos(limbSwing * 0.6662F) * 1.4F * (limbSwingAmount / 1.8f) / f6;
if (rotation < 0.0F)
rotation *= -1;
this.cloakback.xRot = 0.0872665F + (rotation / 3);
this.leftlong.xRot = 0.0872665F + (rotation / 3);
this.rightlong.xRot = 0.0872665F + (rotation / 3);
this.leftmedium.xRot = 0.0872665F + (rotation / 3);
this.rightmedium.xRot = 0.0872665F + (rotation / 3);
this.rightshort.xRot = 0.0872665F + (rotation / 3);
this.leftshort.xRot = 0.0872665F + (rotation / 3);

if (entity.isCrouching()) {
this.cloakback.xRot += 0.5F;
this.leftlong.xRot += 0.5F;
this.rightlong.xRot += 0.5F;
this.leftmedium.xRot += 0.5F;
this.rightmedium.xRot += 0.5F;
this.leftshort.xRot += 0.5F;
this.rightshort.xRot += 0.5F;
}
}

@Override
protected @NotNull Iterable<ModelPart> getBodyModels() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,10 @@ public void onRenderLivingPre(RenderLivingEvent.@NotNull Pre<Player, PlayerModel
@SubscribeEvent
public void onRenderFirstPersonHand(@NotNull RenderHandEvent event) {
LocalPlayer player = Minecraft.getInstance().player;
if (player != null && event.getHand() == InteractionHand.MAIN_HAND && player.isUsingItem() && player.getUseItemRemainingTicks() > 0) {
if (player.getMainHandItem().getItem() instanceof CrucifixItem) {
int i = player.getMainArm() == HumanoidArm.RIGHT ? 1 : -1;
if (player != null && player.isUsingItem() && player.getUseItemRemainingTicks() > 0 && event.getHand() == player.getUsedItemHand()) {
if (event.getItemStack().getItem() instanceof CrucifixItem) {
HumanoidArm humanoidarm = event.getHand() == InteractionHand.MAIN_HAND ? player.getMainArm() : player.getMainArm().getOpposite();
int i = humanoidarm == HumanoidArm.RIGHT ? 1 : -1;
event.getPoseStack().translate(((float) -i * 0.56F), -0.0, -0.2F);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.teamlapen.vampirism.command.test;

import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.builder.ArgumentBuilder;
import de.teamlapen.lib.lib.util.BasicCommand;
import de.teamlapen.vampirism.api.EnumStrength;
Expand All @@ -19,14 +20,14 @@ public class GarlicCheckCommand extends BasicCommand {
return Commands.literal("garlicCheck")
.requires(context -> context.hasPermission(PERMISSION_LEVEL_CHEAT))
.executes(context -> garlicCheck(context.getSource(), context.getSource().getPlayerOrException(), false))
.then(Commands.literal("print"))
.executes(context -> garlicCheck(context.getSource(), context.getSource().getPlayerOrException(), true));
.then(Commands.argument("print", BoolArgumentType.bool())
.executes(context -> garlicCheck(context.getSource(), context.getSource().getPlayerOrException(), BoolArgumentType.getBool(context, "print"))));
}

@SuppressWarnings("SameReturnValue")
private static int garlicCheck(@NotNull CommandSourceStack commandSource, @NotNull ServerPlayer asPlayer, boolean print) {
if (commandSource.getEntity() != null && commandSource.getEntity() instanceof Player) {
commandSource.sendSuccess(() -> Component.translatable("command.vampirism.test.garliccheck.strength" + VampirismAPI.getVampirismWorld(asPlayer.getCommandSenderWorld()).map(w -> w.getStrengthAtChunk(new ChunkPos(asPlayer.blockPosition()))).orElse(EnumStrength.NONE)), true);
commandSource.sendSuccess(() -> Component.translatable("command.vampirism.test.garliccheck.strength", VampirismAPI.getVampirismWorld(asPlayer.getCommandSenderWorld()).map(w -> w.getStrengthAtChunk(new ChunkPos(asPlayer.blockPosition()))).orElse(EnumStrength.NONE)), true);
}
if (print) {
VampirismWorld.getOpt(asPlayer.getCommandSenderWorld()).ifPresent(vw -> vw.printDebug(commandSource));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import de.teamlapen.vampirism.world.MinionWorldData;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -54,10 +56,18 @@ public class MinionCommand extends BasicCommand {
)
)
)
.then(Commands.literal("recall").executes(context -> recall(context.getSource())))
.then(Commands.literal("respawnAll").executes(context -> respawn(context.getSource())))
.then(Commands.literal("purge").executes(context -> purge(context.getSource())))
.executes(context -> 0);
.then(Commands.literal("recall")
.executes(context -> recall(context.getSource(), context.getSource().getPlayerOrException()))
.then(Commands.argument("target", EntityArgument.player())
.executes(context -> recall(context.getSource(), EntityArgument.getPlayer(context, "target")))))
.then(Commands.literal("respawnAll")
.executes(context -> respawn(context.getSource(), context.getSource().getPlayerOrException()))
.then(Commands.argument("target", EntityArgument.player())
.executes(context -> respawn(context.getSource(), EntityArgument.getPlayer(context, "target")))))
.then(Commands.literal("purge")
.executes(context -> purge(context.getSource(), context.getSource().getPlayerOrException()))
.then(Commands.argument("target", EntityArgument.player())
.executes(context -> purge(context.getSource(), EntityArgument.getPlayer(context, "target")))));
}


Expand Down Expand Up @@ -104,14 +114,13 @@ private static <T extends MinionData> int spawnNewMinion(@NotNull CommandSourceS
}

@SuppressWarnings("SameReturnValue")
private static int recall(@NotNull CommandSourceStack ctx) throws CommandSyntaxException {
Player p = ctx.getPlayerOrException();
FactionPlayerHandler fph = FactionPlayerHandler.get(p);
private static int recall(@NotNull CommandSourceStack ctx, ServerPlayer player) throws CommandSyntaxException {
FactionPlayerHandler fph = FactionPlayerHandler.get(player);
if (fph.getMaxMinions() > 0) {
PlayerMinionController controller = MinionWorldData.getData(ctx.getServer()).getOrCreateController(fph);
Collection<Integer> ids = controller.recallMinions(true);
for (Integer id : ids) {
controller.createMinionEntityAtPlayer(id, p);
controller.createMinionEntityAtPlayer(id, player);
}
} else {
throw fail.create("Can't have minions");
Expand All @@ -122,14 +131,13 @@ private static int recall(@NotNull CommandSourceStack ctx) throws CommandSyntaxE


@SuppressWarnings("SameReturnValue")
private static int respawn(@NotNull CommandSourceStack ctx) throws CommandSyntaxException {
Player p = ctx.getPlayerOrException();
FactionPlayerHandler fph = FactionPlayerHandler.get(p);
private static int respawn(@NotNull CommandSourceStack ctx, ServerPlayer player) throws CommandSyntaxException {
FactionPlayerHandler fph = FactionPlayerHandler.get(player);
if (fph.getMaxMinions() > 0) {
PlayerMinionController controller = MinionWorldData.getData(ctx.getServer()).getOrCreateController(fph);
Collection<Integer> ids = controller.getUnclaimedMinions();
for (Integer id : ids) {
controller.createMinionEntityAtPlayer(id, p);
controller.createMinionEntityAtPlayer(id, player);
}

} else {
Expand All @@ -140,10 +148,9 @@ private static int respawn(@NotNull CommandSourceStack ctx) throws CommandSyntax
}

@SuppressWarnings("SameReturnValue")
private static int purge(@NotNull CommandSourceStack ctx) throws CommandSyntaxException {
Player p = ctx.getPlayerOrException();
MinionWorldData.getData(ctx.getServer()).purgeController(p.getUUID());
p.displayClientMessage(Component.literal("Reload world"), false);
private static int purge(@NotNull CommandSourceStack ctx, ServerPlayer player) throws CommandSyntaxException {
MinionWorldData.getData(ctx.getServer()).purgeController(player.getUUID());
((Player) player).displayClientMessage(Component.literal("Reload world"), false);
return 0;
}
}
Loading

0 comments on commit 829fdf6

Please sign in to comment.