Remove unnecessary state parameters
This commit is contained in:
parent
d0d4d8f257
commit
271bb0165e
|
@ -96,7 +96,7 @@ public abstract class Multipart {
|
||||||
public abstract VoxelShape getBoundingShape(MultipartState state, /*@Nullable*/ MultipartView view);
|
public abstract VoxelShape getBoundingShape(MultipartState state, /*@Nullable*/ MultipartView view);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The loot table ID used for to determine the drops by the default {@link Multipart#getDroppedStacks(MultipartState, MultipartView, LootContext.Builder)} implementation.
|
* @return The loot table ID used for to determine the drops by the default {@link Multipart#getDroppedStacks(MultipartView, LootContext.Builder)} implementation.
|
||||||
*/
|
*/
|
||||||
public Identifier getDropTableId() {
|
public Identifier getDropTableId() {
|
||||||
if (dropTableId == null) {
|
if (dropTableId == null) {
|
||||||
|
@ -111,18 +111,17 @@ public abstract class Multipart {
|
||||||
*
|
*
|
||||||
* Can be overridden, should only be called via {@link MultipartState#getDroppedStacks)}
|
* Can be overridden, should only be called via {@link MultipartState#getDroppedStacks)}
|
||||||
*
|
*
|
||||||
* @param state The state of this part.
|
|
||||||
* @param view The view of this part.
|
* @param view The view of this part.
|
||||||
* @param builder The {@link LootContext} builder, used by the default loot table-based implementation.
|
* @param builder The {@link LootContext} builder, used by the default loot table-based implementation.
|
||||||
* @return The list of stacks to drop.
|
* @return The list of stacks to drop.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public List<ItemStack> getDroppedStacks(MultipartState state, MultipartView view, LootContext.Builder builder) {
|
public List<ItemStack> getDroppedStacks(MultipartView view, LootContext.Builder builder) {
|
||||||
Identifier dropTableId = getDropTableId();
|
Identifier dropTableId = getDropTableId();
|
||||||
if (dropTableId == LootTables.EMPTY) {
|
if (dropTableId == LootTables.EMPTY) {
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
} else {
|
} else {
|
||||||
LootContext context = builder.put(SimpleMultipart.MULTIPART_STATE_PARAMETER, state).build(SimpleMultipart.MULTIPART_LOOT_CONTEXT);
|
LootContext context = builder.put(SimpleMultipart.MULTIPART_STATE_PARAMETER, view.getState()).build(SimpleMultipart.MULTIPART_LOOT_CONTEXT);
|
||||||
ServerWorld world = context.getWorld();
|
ServerWorld world = context.getWorld();
|
||||||
LootSupplier supplier = world.getServer().getLootManager().getSupplier(dropTableId);
|
LootSupplier supplier = world.getServer().getLootManager().getSupplier(dropTableId);
|
||||||
return supplier.getDrops(context);
|
return supplier.getDrops(context);
|
||||||
|
@ -134,14 +133,13 @@ public abstract class Multipart {
|
||||||
*
|
*
|
||||||
* Can be overridden, should only be called via {@link MultipartState#activate}
|
* Can be overridden, should only be called via {@link MultipartState#activate}
|
||||||
*
|
*
|
||||||
* @param state The state of this part.
|
|
||||||
* @param view The view of this part.
|
* @param view The view of this part.
|
||||||
* @param player The player that activated this part.
|
* @param player The player that activated this part.
|
||||||
* @param hand The hand with which they performed the action.
|
* @param hand The hand with which they performed the action.
|
||||||
* @return If the activation was successful. {@code true} will trigger the hand-swinging animation.
|
* @return If the activation was successful. {@code true} will trigger the hand-swinging animation.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean activate(MultipartState state, MultipartView view, PlayerEntity player, Hand hand) {
|
public boolean activate(MultipartView view, PlayerEntity player, Hand hand) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,19 +41,19 @@ public class MultipartState extends AbstractPropertyContainer<Multipart, Multipa
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Multipart#getDroppedStacks(MultipartState, MultipartView, LootContext.Builder)
|
* @see Multipart#getDroppedStacks(MultipartView, LootContext.Builder)
|
||||||
*/
|
*/
|
||||||
public List<ItemStack> getDroppedStacks(MultipartView view, LootContext.Builder builder) {
|
public List<ItemStack> getDroppedStacks(MultipartView view, LootContext.Builder builder) {
|
||||||
//noinspection deprecated
|
//noinspection deprecated
|
||||||
return owner.getDroppedStacks(this, view, builder);
|
return owner.getDroppedStacks(view, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Multipart#activate(MultipartState, MultipartView, PlayerEntity, Hand)
|
* @see Multipart#activate(MultipartView, PlayerEntity, Hand)
|
||||||
*/
|
*/
|
||||||
public boolean activate(MultipartView view, PlayerEntity player, Hand hand) {
|
public boolean activate(MultipartView view, PlayerEntity player, Hand hand) {
|
||||||
//noinspection deprecated
|
//noinspection deprecated
|
||||||
return owner.activate(this, view, player, hand);
|
return owner.activate(view, player, hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class EntityTestPart extends Multipart implements MultipartEntityProvider
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean activate(MultipartState state, MultipartView view, PlayerEntity player, Hand hand) {
|
public boolean activate(MultipartView view, PlayerEntity player, Hand hand) {
|
||||||
BlockPos pos = ((Entity)view.getEntity()).getPos();
|
BlockPos pos = ((Entity)view.getEntity()).getPos();
|
||||||
player.addChatMessage(new StringTextComponent("Clicked: " + pos), false);
|
player.addChatMessage(new StringTextComponent("Clicked: " + pos), false);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -56,8 +56,8 @@ public class TestMultipart extends Multipart {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean activate(MultipartState state, MultipartView view, PlayerEntity player, Hand hand) {
|
public boolean activate(MultipartView view, PlayerEntity player, Hand hand) {
|
||||||
Direction side = state.get(Properties.FACING);
|
Direction side = view.getState().get(Properties.FACING);
|
||||||
System.out.println("part activated on " + side);
|
System.out.println("part activated on " + side);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class TickableEntityTestPart extends Multipart implements MultipartEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean activate(MultipartState state, MultipartView view, PlayerEntity player, Hand hand) {
|
public boolean activate(MultipartView view, PlayerEntity player, Hand hand) {
|
||||||
int timer = ((Entity)view.getEntity()).timer;
|
int timer = ((Entity)view.getEntity()).timer;
|
||||||
player.addChatMessage(new StringTextComponent("Timer: " + timer), false);
|
player.addChatMessage(new StringTextComponent("Timer: " + timer), false);
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue