Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to see smoother movements #16

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void spawn(Player player) {
}

capeDisplay = NmsHandlerFactory.getDisplayItem();
capeDisplay.spawn(player.getLocation(), capeItem);
capeDisplay.spawn(player.getLocation(), capeItem, 20);

float height = 1.9f;
Transformation transformation = capeDisplay.getTransformation();
Expand Down Expand Up @@ -271,7 +271,7 @@ public IDisplayItem getCapeDisplay() {

public void visible(boolean visibility) {
if (visibility) {
capeDisplay.spawn(player.getLocation(), capeItem);
capeDisplay.spawn(player.getLocation(), capeItem, 0);
float height = 1.9f;
Transformation transformation = capeDisplay.getTransformation();
transformation.getScale().set(1.2f, height, 0.08f);
Expand Down
4 changes: 3 additions & 1 deletion Core/src/main/java/fr/cocoraid/prodigycape/IDisplayItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Transformation;

import javax.annotation.Nullable;

public interface IDisplayItem {

void spawn(Location location, ItemStack itemStack);
void spawn(Location location, ItemStack itemStack, @Nullable Integer interpolationDuration);
void spawn(Player player);
void despawn();
void despawn(Player player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Transformation;

import javax.annotation.Nullable;

public class DisplayItem_1_19_4 implements IDisplayItem {

private DisplayItemNMS displayItemNMS;

@Override
public void spawn(Location location, ItemStack itemStack) {
public void spawn(Location location, ItemStack itemStack, @Nullable Integer interpolationDuration) {
displayItemNMS = new DisplayItemNMS(location.getWorld());
displayItemNMS.setLocation(location);
displayItemNMS.setInterpolationDuration(interpolationDuration);
displayItemNMS.setItemStack(itemStack);
displayItemNMS.spawn();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public DisplayNMS(World world, String name, Entity entity) {

}

public void setInterpolationDuration(Integer duration) {
if(duration == null) {
display.setInterpolationDuration(0);
return;
}
display.setInterpolationDuration(duration);
}

public DisplayNMS setViewRange (int viewDistance) {
display.setViewRange(viewDistance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Transformation;

import javax.annotation.Nullable;

public class DisplayItem_1_20_1 implements IDisplayItem {

private DisplayItemNMS displayItemNMS;

@Override
public void spawn(Location location, ItemStack itemStack) {
public void spawn(Location location, ItemStack itemStack, @Nullable Integer interpolationDuration) {
displayItemNMS = new DisplayItemNMS(location.getWorld());
displayItemNMS.setLocation(location);
displayItemNMS.setInterpolationDuration(interpolationDuration);
displayItemNMS.setItemStack(itemStack);
displayItemNMS.spawn();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ public DisplayNMS(World world, String name, Entity entity) {

}

public void setInterpolationDuration(Integer duration) {
if(duration == null) {
display.setInterpolationDuration(0);
return;
}
display.setInterpolationDuration(duration);
}


public DisplayNMS setViewRange (int viewDistance) {
display.setViewRange(viewDistance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Transformation;

import javax.annotation.Nullable;

public class DisplayItem_1_20_2 implements IDisplayItem {

private DisplayItemNMS displayItemNMS;

@Override
public void spawn(Location location, ItemStack itemStack) {
public void spawn(Location location, ItemStack itemStack, @Nullable Integer interpolationDuration) {
displayItemNMS = new DisplayItemNMS(location.getWorld());
displayItemNMS.setLocation(location);
displayItemNMS.setInterpolationDuration(interpolationDuration);
displayItemNMS.setItemStack(itemStack);
displayItemNMS.spawn();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ public DisplayNMS(World world, String name, Entity entity) {

}

public void setInterpolationDuration(Integer duration) {
if(duration == null) {
display.setTransformationInterpolationDuration(0);
return;
}
display.setTransformationInterpolationDuration(duration);
}


public DisplayNMS setViewRange (int viewDistance) {
display.setViewRange(viewDistance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Transformation;

import javax.annotation.Nullable;

public class DisplayItem_1_20_4 implements IDisplayItem {

private DisplayItemNMS displayItemNMS;

@Override
public void spawn(Location location, ItemStack itemStack) {
public void spawn(Location location, ItemStack itemStack, @Nullable Integer interpolationDuration) {
displayItemNMS = new DisplayItemNMS(location.getWorld());
displayItemNMS.setLocation(location);
displayItemNMS.setItemStack(itemStack);
displayItemNMS.setInterpolationDuration(interpolationDuration);
displayItemNMS.spawn();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public DisplayNMS(World world, String name, Entity entity) {

}

public void setInterpolationDuration(Integer duration) {
if(duration == null) {
display.setTransformationInterpolationDuration(0);
return;
}
display.setTransformationInterpolationDuration(duration);
}

public DisplayNMS setViewRange (int viewDistance) {
display.setViewRange(viewDistance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@
import org.bukkit.util.Transformation;
import fr.cocoraid.prodigycape.support.entities_1_20_6.DisplayItemNMS;

import javax.annotation.Nullable;

public class DisplayItem_1_20_6 implements IDisplayItem {

private DisplayItemNMS displayItemNMS;

@Override
public void spawn(Location location, ItemStack itemStack) {
public void spawn(Location location, ItemStack itemStack, @Nullable Integer interpolationDuration) {
displayItemNMS = new DisplayItemNMS(location.getWorld());
displayItemNMS.setLocation(location);
displayItemNMS.setItemStack(itemStack);
displayItemNMS.setInterpolationDuration(interpolationDuration);
displayItemNMS.spawn();
}


@Override
public void spawn(Player player) {
displayItemNMS.spawn(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ public DisplayNMS(World world, String name, Entity entity) {

}

public void setInterpolationDuration(Integer duration) {
if(duration == null) {
display.setTransformationInterpolationDuration(0);
return;
}
display.setTransformationInterpolationDuration(duration);
}


public DisplayNMS setViewRange (int viewDistance) {
display.setViewRange(viewDistance);
Expand Down