SimpleMultipart/src/main/java/net/shadowfacts/simplemultipart/multipart/MultipartState.java

61 lines
1.7 KiB
Java
Raw Normal View History

2018-12-20 00:39:10 +00:00
package net.shadowfacts.simplemultipart.multipart;
import com.google.common.collect.ImmutableMap;
2018-12-20 01:44:53 +00:00
import net.minecraft.entity.player.PlayerEntity;
2018-12-20 00:39:10 +00:00
import net.minecraft.item.ItemStack;
import net.minecraft.state.AbstractPropertyContainer;
import net.minecraft.state.property.Property;
2018-12-20 01:44:53 +00:00
import net.minecraft.util.Hand;
2018-12-29 23:45:36 +00:00
import net.minecraft.util.math.Direction;
2018-12-20 00:39:10 +00:00
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.loot.context.LootContext;
import java.util.List;
/**
2018-12-28 18:10:59 +00:00
* A container for a {@link Multipart} and its associated properties/values.
*
* Analogous to {@link net.minecraft.block.BlockState}.
*
2018-12-20 00:39:10 +00:00
* @author shadowfacts
2018-12-28 18:10:59 +00:00
* @since 0.1.0
2018-12-20 00:39:10 +00:00
*/
public class MultipartState extends AbstractPropertyContainer<Multipart, MultipartState> {
public MultipartState(Multipart part, ImmutableMap<Property<?>, Comparable<?>> properties) {
super(part, properties);
}
2018-12-28 18:10:59 +00:00
/**
* @return The multipart object for this state.
*/
2018-12-20 00:39:10 +00:00
public Multipart getMultipart() {
return owner;
}
2018-12-28 18:10:59 +00:00
/**
* @see Multipart#getBoundingShape(MultipartState, MultipartView)
*/
2018-12-25 15:20:44 +00:00
public VoxelShape getBoundingShape(/*@Nullable*/ MultipartView view) {
2018-12-20 00:39:10 +00:00
//noinspection deprecation
2018-12-25 15:20:44 +00:00
return owner.getBoundingShape(this, view);
2018-12-20 00:39:10 +00:00
}
2018-12-28 18:10:59 +00:00
/**
2018-12-28 18:16:58 +00:00
* @see Multipart#getDroppedStacks(MultipartView, LootContext.Builder)
2018-12-28 18:10:59 +00:00
*/
2018-12-25 15:20:44 +00:00
public List<ItemStack> getDroppedStacks(MultipartView view, LootContext.Builder builder) {
2018-12-20 00:39:10 +00:00
//noinspection deprecated
2018-12-28 18:16:58 +00:00
return owner.getDroppedStacks(view, builder);
2018-12-20 00:39:10 +00:00
}
2018-12-28 18:10:59 +00:00
/**
2018-12-29 23:45:36 +00:00
* @see Multipart#activate(MultipartView, Direction, PlayerEntity, Hand)
2018-12-28 18:10:59 +00:00
*/
2018-12-29 23:45:36 +00:00
public boolean activate(MultipartView view, Direction side, PlayerEntity player, Hand hand) {
2018-12-20 01:44:53 +00:00
//noinspection deprecated
2018-12-29 23:45:36 +00:00
return owner.activate(view, side, player, hand);
2018-12-20 01:44:53 +00:00
}
2018-12-20 00:39:10 +00:00
}