Add hit side to Multipart::activate

This commit is contained in:
Shadowfacts 2018-12-29 18:45:36 -05:00
parent 7c465d01f4
commit f0e150664d
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
6 changed files with 13 additions and 9 deletions

View File

@ -39,7 +39,7 @@ public abstract class AbstractContainerBlock extends Block implements BlockEntit
return false;
}
return hit.view.getState().activate(hit.view, player, hand);
return hit.view.getState().activate(hit.view, hit.side, player, hand);
}
@Override

View File

@ -16,7 +16,6 @@ import net.shadowfacts.simplemultipart.SimpleMultipart;
import net.shadowfacts.simplemultipart.util.MultipartPlacementContext;
import java.util.List;
import java.util.Random;
/**
* The base class for a multipart object.
@ -134,12 +133,13 @@ public abstract class Multipart {
* Can be overridden, should only be called via {@link MultipartState#activate}
*
* @param view The view of this part.
* @param side The side of the part that was hit.
* @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(MultipartView view, PlayerEntity player, Hand hand) {
public boolean activate(MultipartView view, Direction side, PlayerEntity player, Hand hand) {
return false;
}

View File

@ -6,6 +6,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.state.AbstractPropertyContainer;
import net.minecraft.state.property.Property;
import net.minecraft.util.Hand;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.loot.context.LootContext;
@ -49,11 +50,11 @@ public class MultipartState extends AbstractPropertyContainer<Multipart, Multipa
}
/**
* @see Multipart#activate(MultipartView, PlayerEntity, Hand)
* @see Multipart#activate(MultipartView, Direction, PlayerEntity, Hand)
*/
public boolean activate(MultipartView view, PlayerEntity player, Hand hand) {
public boolean activate(MultipartView view, Direction side, PlayerEntity player, Hand hand) {
//noinspection deprecated
return owner.activate(view, player, hand);
return owner.activate(view, side, player, hand);
}
}

View File

@ -4,6 +4,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.StringTextComponent;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.shadowfacts.simplemultipart.container.MultipartContainer;
@ -27,7 +28,7 @@ public class EntityTestPart extends Multipart implements MultipartEntityProvider
@Override
@Deprecated
public boolean activate(MultipartView view, PlayerEntity player, Hand hand) {
public boolean activate(MultipartView view, Direction side, PlayerEntity player, Hand hand) {
BlockPos pos = ((Entity)view.getEntity()).getPos();
player.addChatMessage(new StringTextComponent("Clicked: " + pos), false);
return true;

View File

@ -56,7 +56,7 @@ public class TestMultipart extends Multipart {
@Override
@Deprecated
public boolean activate(MultipartView view, PlayerEntity player, Hand hand) {
public boolean activate(MultipartView view, Direction side, PlayerEntity player, Hand hand) {
System.out.println(view.getContainer().getPart(Direction.UP));
return true;
}

View File

@ -4,6 +4,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.StringTextComponent;
import net.minecraft.util.Hand;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.shadowfacts.simplemultipart.container.MultipartContainer;
@ -26,9 +27,10 @@ public class TickableEntityTestPart extends Multipart implements MultipartEntity
@Override
@Deprecated
public boolean activate(MultipartView view, PlayerEntity player, Hand hand) {
public boolean activate(MultipartView view, Direction side, PlayerEntity player, Hand hand) {
int timer = ((Entity)view.getEntity()).timer;
player.addChatMessage(new StringTextComponent("Timer: " + timer), false);
System.out.println("hit side: " + side);
return true;
}