Add container/view methods for getting the world and pos
This commit is contained in:
parent
f0e150664d
commit
5ad5d569c3
|
@ -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);
|
||||||
|
|
|
@ -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.
|
||||||
*
|
*
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue