Remove unnecessary state parameters

This commit is contained in:
Shadowfacts 2018-12-28 13:16:58 -05:00
parent d0d4d8f257
commit 271bb0165e
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
5 changed files with 12 additions and 14 deletions

View File

@ -96,7 +96,7 @@ public abstract class Multipart {
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() {
if (dropTableId == null) {
@ -111,18 +111,17 @@ public abstract class Multipart {
*
* 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 builder The {@link LootContext} builder, used by the default loot table-based implementation.
* @return The list of stacks to drop.
*/
@Deprecated
public List<ItemStack> getDroppedStacks(MultipartState state, MultipartView view, LootContext.Builder builder) {
public List<ItemStack> getDroppedStacks(MultipartView view, LootContext.Builder builder) {
Identifier dropTableId = getDropTableId();
if (dropTableId == LootTables.EMPTY) {
return ImmutableList.of();
} 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();
LootSupplier supplier = world.getServer().getLootManager().getSupplier(dropTableId);
return supplier.getDrops(context);
@ -134,14 +133,13 @@ public abstract class Multipart {
*
* 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 player The player that activated this part.
* @param hand The hand with which they performed the action.
* @return If the activation was successful. {@code true} will trigger the hand-swinging animation.
*/
@Deprecated
public boolean activate(MultipartState state, MultipartView view, PlayerEntity player, Hand hand) {
public boolean activate(MultipartView view, PlayerEntity player, Hand hand) {
return false;
}

View File

@ -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) {
//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) {
//noinspection deprecated
return owner.activate(this, view, player, hand);
return owner.activate(view, player, hand);
}
}

View File

@ -27,7 +27,7 @@ public class EntityTestPart extends Multipart implements MultipartEntityProvider
@Override
@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();
player.addChatMessage(new StringTextComponent("Clicked: " + pos), false);
return true;

View File

@ -56,8 +56,8 @@ public class TestMultipart extends Multipart {
@Override
@Deprecated
public boolean activate(MultipartState state, MultipartView view, PlayerEntity player, Hand hand) {
Direction side = state.get(Properties.FACING);
public boolean activate(MultipartView view, PlayerEntity player, Hand hand) {
Direction side = view.getState().get(Properties.FACING);
System.out.println("part activated on " + side);
return true;
}

View File

@ -26,7 +26,7 @@ public class TickableEntityTestPart extends Multipart implements MultipartEntity
@Override
@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;
player.addChatMessage(new StringTextComponent("Timer: " + timer), false);
return true;