Add container/view methods for getting the world and pos

This commit is contained in:
Shadowfacts 2019-01-01 18:40:38 -05:00
parent f0e150664d
commit 5ad5d569c3
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
3 changed files with 39 additions and 0 deletions

View File

@ -17,6 +17,7 @@ import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.World;
import net.minecraft.world.loot.context.LootContext; import net.minecraft.world.loot.context.LootContext;
import net.minecraft.world.loot.context.Parameters; import net.minecraft.world.loot.context.Parameters;
import net.shadowfacts.simplemultipart.SimpleMultipart; import net.shadowfacts.simplemultipart.SimpleMultipart;
@ -42,6 +43,16 @@ public abstract class AbstractContainerBlockEntity extends BlockEntity implement
super(type); super(type);
} }
@Override
public World getContainerWorld() {
return world;
}
@Override
public BlockPos getContainerPos() {
return pos;
}
@Override @Override
public Set<MultipartView> getParts() { public Set<MultipartView> getParts() {
return ImmutableSet.copyOf(parts); return ImmutableSet.copyOf(parts);

View File

@ -1,6 +1,8 @@
package net.shadowfacts.simplemultipart.container; package net.shadowfacts.simplemultipart.container;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import net.shadowfacts.simplemultipart.multipart.MultipartView; import net.shadowfacts.simplemultipart.multipart.MultipartView;
import net.shadowfacts.simplemultipart.multipart.MultipartState; import net.shadowfacts.simplemultipart.multipart.MultipartState;
@ -15,6 +17,16 @@ import java.util.Set;
*/ */
public interface MultipartContainer { public interface MultipartContainer {
/**
* @return The world that this container is in.
*/
World getContainerWorld();
/**
* @return The position of this container in the world.
*/
BlockPos getContainerPos();
/** /**
* Retrieves all the multiparts held by this container. * Retrieves all the multiparts held by this container.
* *

View File

@ -1,5 +1,7 @@
package net.shadowfacts.simplemultipart.multipart; package net.shadowfacts.simplemultipart.multipart;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.shadowfacts.simplemultipart.container.MultipartContainer; import net.shadowfacts.simplemultipart.container.MultipartContainer;
import net.shadowfacts.simplemultipart.multipart.Multipart; import net.shadowfacts.simplemultipart.multipart.Multipart;
import net.shadowfacts.simplemultipart.multipart.MultipartState; import net.shadowfacts.simplemultipart.multipart.MultipartState;
@ -59,4 +61,18 @@ public interface MultipartView {
return getState().getMultipart(); return getState().getMultipart();
} }
/**
* @return The world that this part's container is in.
*/
default World getWorld() {
return getContainer().getContainerWorld();
}
/**
* @return The position of this part's container.
*/
default BlockPos getPos() {
return getContainer().getContainerPos();
}
} }