Skip to content

Commit

Permalink
Merge branch 'master' into 14.1-features
Browse files Browse the repository at this point in the history
  • Loading branch information
LtxProgrammer committed Nov 29, 2024
2 parents 0397d99 + b3c03d1 commit 33eb4ec
Show file tree
Hide file tree
Showing 23 changed files with 61 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
<version>v0.14</version>
<version>v0.14b</version>
</versions>
<lastUpdated>20241128032210</lastUpdated>
<lastUpdated>20241129180156</lastUpdated>
</versioning>
</metadata>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2c859a28f8b31681397a1e479bda4f5e
a67f0e3cdb76a72e028d564543477824
Original file line number Diff line number Diff line change
@@ -1 +1 @@
71aa43a157b5ae0a0784f4652a943760a386c450
c65a884d3a657f11b5aa791e204736109fdb5ed5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8559bf60f44938c6c9c71ead5da1350551b0c95dcda5296ab09fa3e409a15b26
2f22f7df0c7728ad3ab9f15c2ebbd9aed38d22fae263d5cf4beed36e9d1ec174
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e99538e5153b3bbe9e160e913ed6393dff6200e936b7bd13a584c0e4eb26203896dfe0e5f81b9d4d2b4c3f39df283979be2a0aa471da28ba7838fcdcf18afc49
e79ac19294c90e584dfb581ac75a991253e96e666fb6bc7146ba907d02fa9fe120bc84aa08de660828012c8799c151b078c3b01b17386e1bb513e19df253eb7a
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
db3ddf89372589f4d08db2b0da3e2e29
ddbd6b59374c3e27fee42409b7fb69aa
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e001c3766ac605f3fbd19c9b450a32d5b1e9ebc0
f3cb15af80272afdb934a0105a79adc0a662ea0b
Original file line number Diff line number Diff line change
@@ -1 +1 @@
257ee454b0316dfcf9af29181eb06c38a9629ed63f5fd37201b6952455332ce9
2fe1377226680963003e872a526453dd6deb88e7ee98de24cc14abd88c9c3047
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8b4de85d42dca557c34d8add81d04f2b58cd1af3b312c16155bbc2a6227dfc4bcdbe6acfbd0aa54a2547168dc4bf041f7ce1593be38cb43976fc71e1481f5c8e
0eb81704cfe523510fac3c2672bc6c40ab9c2cf878026b316ea65a60edfbba074a27e065fa07807b488bcbb622eec67dfed7f703f9d0da8e80337ca42f8677ad
13 changes: 12 additions & 1 deletion src/main/java/net/ltxprogrammer/changed/block/RailingBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,18 @@ public BlockState updateShape(BlockState state, Direction direction, BlockState
level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level));
}

return computeState(level, pos, super.updateShape(state, direction, otherState, level, pos, otherPos));
BlockState newState = super.updateShape(state, direction, otherState, level, pos, otherPos);

boolean fullyConnected = newState.getValue(SHAPE).getConnectionDirections(newState.getValue(FACING))
.filter(connectionDirection -> connectionDirection != direction)
.map(connectionDirection ->
canConnect(level, newState, connectionDirection, level.getBlockState(pos.relative(connectionDirection)), pos.relative(connectionDirection)).strength)
.filter(strength -> strength == ConnectionStrength.STRONG).count() == 2;

if (fullyConnected)
return newState;

return computeState(level, pos, newState);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public LocalTransfurVariantInstance(TransfurVariant<T> parent, LocalPlayer host)
protected void tickTransfurProgress() {
super.tickTransfurProgress();

if (transfurProgression < 1f) {
if (transfurProgression < 1f || this.ageAsVariant < 30 || !this.getItemUseMode().holdMainHand) {
((LocalPlayerAccessor)host).setHandsBusy(true);
} else if (host.getVehicle() == null && host.isHandsBusy()) {
((LocalPlayerAccessor)host).setHandsBusy(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ protected boolean runIfValid(SpecialLatex entity, Consumer<SpecialLatexRenderer>
// Returns true if continue with regular code, false if to return, accepts if delegate and valid
protected <R> Optional<R> runIfValid(SpecialLatex entity, Function<SpecialLatexRenderer, R> rendererConsumer) {
if (this.isDelegate) {
if (entity.getAssignedUUID() == null) return Optional.ofNullable(null);
if (entity.getAssignedUUID() == null) return Optional.empty();
PatreonBenefits.SpecialForm form = PatreonBenefits.getPlayerSpecialForm(entity.getAssignedUUID());
if (form == null) return Optional.ofNullable(null);
if (form == null) return Optional.empty();

return Optional.of(rendererConsumer.apply(getAndCacheFor(entity)));
return Optional.ofNullable(rendererConsumer.apply(getAndCacheFor(entity)));
}

else
Expand Down Expand Up @@ -117,11 +117,7 @@ public ResourceLocation getTextureLocation(SpecialLatex latex) {

public AdvancedHumanoidModel<SpecialLatex> getModel(ChangedEntity entity) {
if (entity instanceof SpecialLatex specialLatex) {
var opt = runIfValid(specialLatex, renderer -> { return renderer.getModel(); });
if (opt.isEmpty())
return this.getModel();
else
return opt.get();
return runIfValid(specialLatex, renderer -> { return renderer.getModel(); }).orElseGet(this::getModel);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.ltxprogrammer.changed.item.Syringe;
import net.ltxprogrammer.changed.process.ProcessTransfur;
import net.minecraft.SharedConstants;
import net.minecraft.Util;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
Expand Down Expand Up @@ -49,10 +50,12 @@ public class CommandTransfur {
private static final SimpleCommandExceptionType NOT_CAUSE = new SimpleCommandExceptionType(new TranslatableComponent("command.changed.error.not_cause"));
private static final SimpleCommandExceptionType USED_BY_OTHER_MOD = new SimpleCommandExceptionType(new TranslatableComponent("command.changed.error.used_by_other_mod"));
private static final SimpleCommandExceptionType NO_SPECIAL_FORM = new SimpleCommandExceptionType(new TranslatableComponent("command.changed.error.no_special_form"));
private static final ResourceLocation RANDOM_VARIANT = Changed.modResource("random");

public static final SuggestionProvider<CommandSourceStack> SUGGEST_LATEX_FORMS = SuggestionProviders.register(Changed.modResource("latex_forms"), (p_121667_, p_121668_) -> {
public static final SuggestionProvider<CommandSourceStack> SUGGEST_TRANSFUR_VARIANT = SuggestionProviders.register(Changed.modResource("transfur_variant"), (p_121667_, p_121668_) -> {
var list = TransfurVariant.getPublicTransfurVariants().map(TransfurVariant::getRegistryName).collect(Collectors.toCollection(ArrayList::new));
list.add(TransfurVariant.SPECIAL_LATEX);
list.add(RANDOM_VARIANT);
return SharedSuggestionProvider.suggestResource(list, p_121668_);
});

Expand All @@ -65,7 +68,7 @@ public class CommandTransfur {
public static void registerCommands(RegisterCommandsEvent event) {
var transfurNode = event.getDispatcher().register(Commands.literal("transfur").requires(p -> p.hasPermission(2))
.then(Commands.argument("players", EntityArgument.player())
.then(Commands.argument("form", ResourceLocationArgument.id()).suggests(SUGGEST_LATEX_FORMS)
.then(Commands.argument("form", ResourceLocationArgument.id()).suggests(SUGGEST_TRANSFUR_VARIANT)
.executes(context -> transfurPlayers(context.getSource(),
EntityArgument.getPlayers(context, "players"),
ResourceLocationArgument.getId(context, "form"),
Expand All @@ -79,7 +82,7 @@ public static void registerCommands(RegisterCommandsEvent event) {
event.getDispatcher().register(Commands.literal("tf").requires(p -> p.hasPermission(2)).redirect(transfurNode));
var progressTransfurNode = event.getDispatcher().register(Commands.literal("progresstransfur").requires(p -> p.hasPermission(2))
.then(Commands.argument("players", EntityArgument.players())
.then(Commands.argument("form", ResourceLocationArgument.id()).suggests(SUGGEST_LATEX_FORMS)
.then(Commands.argument("form", ResourceLocationArgument.id()).suggests(SUGGEST_TRANSFUR_VARIANT)
.then(Commands.argument("progression", FloatArgumentType.floatArg(0.0f))
.executes(context -> progressPlayersTransfur(context.getSource(),
EntityArgument.getPlayers(context, "players"),
Expand Down Expand Up @@ -148,6 +151,9 @@ private static int transfurPlayer(CommandSourceStack source, ServerPlayer player
if (ChangedCompatibility.isPlayerUsedByOtherMod(player))
throw USED_BY_OTHER_MOD.create();

if (form.equals(RANDOM_VARIANT))
form = Util.getRandom(TransfurVariant.getPublicTransfurVariants().collect(Collectors.toList()), player.getRandom()).getFormId();

if (TransfurVariant.getPublicTransfurVariants().map(TransfurVariant::getRegistryName).anyMatch(form::equals)) {
ProcessTransfur.transfur(player, source.getLevel(), ChangedRegistry.TRANSFUR_VARIANT.get().getValue(form), true,
TransfurContext.hazard(transfurCause));
Expand Down Expand Up @@ -205,6 +211,9 @@ else if (source.getEntity() instanceof ChangedEntity sourceNpc)
else
context = null;

if (form.equals(RANDOM_VARIANT))
form = Util.getRandom(TransfurVariant.getPublicTransfurVariants().collect(Collectors.toList()), player.getRandom()).getFormId();

if (TransfurVariant.getPublicTransfurVariants().map(TransfurVariant::getRegistryName).anyMatch(form::equals)) {
ProcessTransfur.progressPlayerTransfur(player, progression, ChangedRegistry.TRANSFUR_VARIANT.get().getValue(form), context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.google.common.collect.ImmutableMap;
import com.mojang.datafixers.util.Pair;
import it.unimi.dsi.fastutil.objects.Object2DoubleArrayMap;
import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap;
import net.ltxprogrammer.changed.Changed;
import net.ltxprogrammer.changed.ability.AbstractAbility;
import net.ltxprogrammer.changed.ability.AbstractAbilityInstance;
Expand Down Expand Up @@ -1003,13 +1005,19 @@ public UseItemMode getItemUseMode() {
}

public float getSwimEfficiency() {
double baselineSwim = DEFAULT_PLAYER_ATTRIBUTES.get().getInstance(ForgeMod.SWIM_SPEED.get()).getBaseValue();
if (!newAttributes.containsKey(ForgeMod.SWIM_SPEED.get()))
return 1.0f;

double baselineSwim = DEFAULT_PLAYER_ATTRIBUTES.get().getBaseValue(ForgeMod.SWIM_SPEED.get());
double intendedSwim = newAttributes.get(ForgeMod.SWIM_SPEED.get());
return (float)(baselineSwim / intendedSwim);
}

public float getSprintEfficiency() {
double baselineSprint = DEFAULT_PLAYER_ATTRIBUTES.get().getInstance(Attributes.MOVEMENT_SPEED).getBaseValue();
if (!newAttributes.containsKey(Attributes.MOVEMENT_SPEED))
return 1.0f;

double baselineSprint = DEFAULT_PLAYER_ATTRIBUTES.get().getBaseValue(Attributes.MOVEMENT_SPEED);
double intendedSprint = newAttributes.get(Attributes.MOVEMENT_SPEED) * 0.1;
return (float)(baselineSprint / intendedSprint);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,9 @@ private static TagKey<Biome> create(String name) {
}

public static class TransfurVariants {
public static final TagKey<TransfurVariant<?>> WOLF_LIKE = create("wolf_like");
public static final TagKey<TransfurVariant<?>> SHARK_LIKE = create("shark_like");
public static final TagKey<TransfurVariant<?>> CAT_LIKE = create("cat_like");
public static final TagKey<TransfurVariant<?>> LEOPARD_LIKE = create("leopard_like");

public static final TagKey<TransfurVariant<?>> CAN_SLEEP_ON_PILLOWS = create("can_sleep_on_pillows");
public static final TagKey<TransfurVariant<?>> BREAK_ITEMS_ON_TF = create("break_items_on_tf");
public static final TagKey<TransfurVariant<?>> TEMPORARY_ONLY = create("temporary_only");

private static TagKey<TransfurVariant<?>> create(String name) {
return TagKey.create(ChangedRegistry.TRANSFUR_VARIANT.key, Changed.modResource(name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,6 @@ protected void getSwimSound(CallbackInfoReturnable<SoundEvent> ci) {
}
}

@Inject(method = "hurt", at = @At("HEAD"), cancellable = true)
public void orNotHurt(DamageSource p_36154_, float p_36155_, CallbackInfoReturnable<Boolean> cir) {
ProcessTransfur.ifPlayerTransfurred(EntityUtil.playerOrNull(this), variant -> {
if (variant.ageAsVariant < 30)
cir.cancel();
});
}

@Inject(method = "createAttributes", at = @At("RETURN"))
private static void addChangedAttributes(CallbackInfoReturnable<AttributeSupplier.Builder> cir) {
cir.getReturnValue().add(ChangedAttributes.TRANSFUR_DAMAGE.get(), 3.0D);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import net.ltxprogrammer.changed.Changed;
import net.ltxprogrammer.changed.entity.PlayerDataExtension;
import net.ltxprogrammer.changed.entity.TransfurCause;
import net.ltxprogrammer.changed.entity.UseItemMode;
import net.ltxprogrammer.changed.entity.variant.TransfurVariant;
import net.ltxprogrammer.changed.entity.variant.TransfurVariantInstance;
import net.ltxprogrammer.changed.init.ChangedGameRules;
import net.ltxprogrammer.changed.init.ChangedRegistry;
import net.ltxprogrammer.changed.init.ChangedTags;
import net.ltxprogrammer.changed.init.ChangedTransfurVariants;
import net.ltxprogrammer.changed.network.packet.MountTransfurPacket;
import net.ltxprogrammer.changed.process.Pale;
Expand Down Expand Up @@ -49,8 +51,12 @@ public void restoreFrom(ServerPlayer player, boolean restore, CallbackInfo callb
ProcessTransfur.ifPlayerTransfurred(player, oldVariant -> {
if (!oldVariant.willSurviveTransfur)
return;
if (!restore && oldVariant.getParent().is(ChangedTags.TransfurVariants.TEMPORARY_ONLY))
return; // Exception to keepForm gamerule

var newVariant = ProcessTransfur.setPlayerTransfurVariant(self, oldVariant.getParent(), oldVariant.transfurContext, oldVariant.transfurProgression);
if (newVariant == null)
return;
newVariant.load(oldVariant.save());
newVariant.getChangedEntity().readPlayerVariantData(oldVariant.getChangedEntity().savePlayerVariantData());
newVariant.handleRespawn();
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"changed:form_latex_benign_wolf"
]
}

This file was deleted.

0 comments on commit 33eb4ec

Please sign in to comment.