Skip to content

Commit

Permalink
MeleeRenderer + Transition
Browse files Browse the repository at this point in the history
  • Loading branch information
strubium committed Nov 5, 2024
1 parent d89924f commit b4a079a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/paneedah/weaponlib/WeaponRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2666,7 +2666,7 @@ private List<MultipartTransition<Part, RenderContext<RenderableState>>> getCompl
.withPartPositionFunction(Part.RIGHT_HAND, createWeaponPartPositionFunction(r));


t.sound = p.getSound();
t.sound = p.getSoundEvent();


for (Entry<Part, List<Transition<RenderContext<RenderableState>>>> e : custom.entrySet()) {
Expand Down
47 changes: 8 additions & 39 deletions src/main/java/com/paneedah/weaponlib/animation/Transition.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.paneedah.weaponlib.animation;

import com.paneedah.weaponlib.Part;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.util.SoundEvent;

import java.util.function.Consumer;
Expand All @@ -14,13 +16,12 @@ public static <T> Consumer<T> anchoredPosition() {
return (Consumer<T>) ANCHORED_POSITION;
}

private final Consumer<Context> itemPositioning;
private long duration;
private final long pause;
private final Part attachedTo;
private boolean animated;

private SoundEvent evt;
@Getter private final Consumer<Context> itemPositioning;
@Getter @Setter private long duration;
@Getter private final long pause;
@Getter private final Part attachedTo;
@Getter private boolean animated;
@Getter @Setter private SoundEvent soundEvent;

public Transition(Consumer<Context> itemPositioning, Part attachedTo, boolean animated) {
this(itemPositioning, 0, 0);
Expand All @@ -35,42 +36,10 @@ public Transition(Consumer<Context> itemPositioning, long duration, long pause)
this(itemPositioning, duration, pause, null);
}

public void setSound(SoundEvent event) {
this.evt = event;
}

public Transition(Consumer<Context> itemPositioning, long duration, long pause, Part attachedTo) {
this.itemPositioning = itemPositioning;
this.duration = duration;
this.pause = pause;
this.attachedTo = attachedTo;
}

public Consumer<Context> getItemPositioning() {
return itemPositioning;
}

public void setDuration(long newDuration) {
this.duration = newDuration;
}

public long getDuration() {
return duration;
}

public SoundEvent getSound() {
return this.evt;
}

public long getPause() {
return pause;
}

public Part getAttachedTo() {
return attachedTo;
}

public boolean isAnimated() {
return animated;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ public Transition<?> createVMWTransitionWithADS(Transform normal, Transform ads,

}, (int) timestamp);
// System.out.println("Hello?! Brother! " + sound);
trans.setSound(sound);
trans.setSoundEvent(sound);

return trans;

Expand Down Expand Up @@ -661,7 +661,7 @@ public Transition<?> createVMWTransition(Transform t, double divisor) {


//System.out.println("Hello?! Brother! " + sound);
trans.setSound(sound);
trans.setSoundEvent(sound);
return trans;

}
Expand Down
37 changes: 8 additions & 29 deletions src/main/java/com/paneedah/weaponlib/melee/MeleeRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.paneedah.weaponlib.animation.*;
import com.paneedah.weaponlib.animation.DebugPositioner.TransitionConfiguration;
import com.paneedah.weaponlib.animation.MultipartPositioning.Positioner;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.BufferBuilder;
Expand Down Expand Up @@ -91,14 +93,14 @@ public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, W

public static class Builder {

private ModelBase model;
private String textureName;
@Getter private ModelBase model;
@Getter private String textureName;

private BiConsumer<Part, RenderContext<RenderableState>> partDebugPositioning;

private Consumer<ItemStack> entityPositioning;
private Consumer<ItemStack> inventoryPositioning;
private Consumer<RenderContext<RenderableState>> thirdPersonPositioning;
@Getter private Consumer<ItemStack> entityPositioning;
@Getter private Consumer<ItemStack> inventoryPositioning;
@Getter private Consumer<RenderContext<RenderableState>> thirdPersonPositioning;

private Consumer<RenderContext<RenderableState>> firstPersonPositioning;
private Consumer<RenderContext<RenderableState>> firstPersonPositioningRunning;
Expand Down Expand Up @@ -465,25 +467,6 @@ public MeleeRenderer build() {
return renderer;
}

public Consumer<ItemStack> getEntityPositioning() {
return entityPositioning;
}

public Consumer<ItemStack> getInventoryPositioning() {
return inventoryPositioning;
}

public Consumer<RenderContext<RenderableState>> getThirdPersonPositioning() {
return thirdPersonPositioning;
}

public String getTextureName() {
return textureName;
}

public ModelBase getModel() {
return model;
}
}

private final Builder builder;
Expand All @@ -492,7 +475,7 @@ public ModelBase getModel() {

private final MultipartTransitionProvider<RenderableState, Part, RenderContext<RenderableState>> weaponTransitionProvider;

protected ClientModContext clientModContext;
@Setter protected ClientModContext clientModContext;

private MeleeRenderer(Builder builder) {
this.builder = builder;
Expand All @@ -514,10 +497,6 @@ protected ClientModContext getClientModContext() {
return clientModContext;
}

public void setClientModContext(ClientModContext clientModContext) {
this.clientModContext = clientModContext;
}

protected StateDescriptor getStateDescriptor(EntityPlayer player, ItemStack itemStack) {
float amplitude = builder.normalRandomizingAmplitude;
float rate = builder.normalRandomizingRate;
Expand Down

0 comments on commit b4a079a

Please sign in to comment.