Merge branch 'Shopping' into Kinetics
This commit is contained in:
commit
79d160e5bc
22 changed files with 433 additions and 41 deletions
|
@ -31,6 +31,7 @@ import com.simibubi.create.modules.logistics.StockswitchBlock;
|
|||
import com.simibubi.create.modules.schematics.block.CreativeCrateBlock;
|
||||
import com.simibubi.create.modules.schematics.block.SchematicTableBlock;
|
||||
import com.simibubi.create.modules.schematics.block.SchematicannonBlock;
|
||||
import com.simibubi.create.modules.shopping.ShopShelfBlock;
|
||||
import com.simibubi.create.modules.symmetry.block.CrossPlaneSymmetryBlock;
|
||||
import com.simibubi.create.modules.symmetry.block.PlaneSymmetryBlock;
|
||||
import com.simibubi.create.modules.symmetry.block.TriplePlaneSymmetryBlock;
|
||||
|
@ -102,6 +103,9 @@ public enum AllBlocks {
|
|||
// Gardens
|
||||
COCOA_LOG(new CocoaLogBlock()),
|
||||
|
||||
// Economy
|
||||
SHOP_SHELF(new ShopShelfBlock()),
|
||||
|
||||
// Palettes
|
||||
ANDESITE_BRICKS(new Block(Properties.from(Blocks.ANDESITE))),
|
||||
DIORITE_BRICKS(new Block(Properties.from(Blocks.DIORITE))),
|
||||
|
|
|
@ -6,6 +6,8 @@ import com.simibubi.create.modules.schematics.block.SchematicTableContainer;
|
|||
import com.simibubi.create.modules.schematics.block.SchematicTableScreen;
|
||||
import com.simibubi.create.modules.schematics.block.SchematicannonContainer;
|
||||
import com.simibubi.create.modules.schematics.block.SchematicannonScreen;
|
||||
import com.simibubi.create.modules.shopping.ShopShelfContainer;
|
||||
import com.simibubi.create.modules.shopping.ShopShelfScreen;
|
||||
|
||||
import net.minecraft.client.gui.IHasContainer;
|
||||
import net.minecraft.client.gui.ScreenManager;
|
||||
|
@ -30,6 +32,8 @@ public enum AllContainers {
|
|||
Schematicannon(SchematicannonContainer::new),
|
||||
FlexCrate(FlexcrateContainer::new),
|
||||
|
||||
ShopShelf(ShopShelfContainer::new),
|
||||
|
||||
;
|
||||
|
||||
public ContainerType<? extends Container> type;
|
||||
|
@ -54,6 +58,7 @@ public enum AllContainers {
|
|||
bind(SchematicTable, SchematicTableScreen::new);
|
||||
bind(Schematicannon, SchematicannonScreen::new);
|
||||
bind(FlexCrate, FlexcrateScreen::new);
|
||||
bind(ShopShelf, ShopShelfScreen::new);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
|
|
@ -30,22 +30,26 @@ import net.minecraftforge.registries.IForgeRegistry;
|
|||
public enum AllItems {
|
||||
|
||||
SYMMETRY_WAND(new SymmetryWandItem(
|
||||
standardProperties().rarity(Rarity.UNCOMMON).setTEISR(() -> () -> withSpecialRenderer("wand")))),
|
||||
PLACEMENT_HANDGUN(new BuilderGunItem(
|
||||
new Properties().rarity(Rarity.UNCOMMON).setTEISR(() -> () -> withSpecialRenderer("gun")))),
|
||||
standardProperties().setTEISR(() -> () -> renderUsing(AllItemRenderers.SYMMETRY_WAND)))),
|
||||
|
||||
ANDESITE_ALLOY_CUBE(new Item(standardProperties())), BLAZE_BRASS_CUBE(new Item(standardProperties())),
|
||||
PLACEMENT_HANDGUN(
|
||||
new BuilderGunItem(new Properties().setTEISR(() -> () -> renderUsing(AllItemRenderers.BUILDER_GUN)))),
|
||||
|
||||
ANDESITE_ALLOY_CUBE(new Item(standardProperties())),
|
||||
BLAZE_BRASS_CUBE(new Item(standardProperties())),
|
||||
CHORUS_CHROME_CUBE(new Item(standardProperties().rarity(Rarity.UNCOMMON))),
|
||||
|
||||
TREE_FERTILIZER(new TreeFertilizerItem(standardProperties())),
|
||||
|
||||
EMPTY_BLUEPRINT(new Item(standardProperties().maxStackSize(1))),
|
||||
BLUEPRINT_AND_QUILL(new BlueprintAndQuillItem(standardProperties().maxStackSize(1))),
|
||||
BLUEPRINT(new BlueprintItem(standardProperties())),
|
||||
|
||||
BELT_CONNECTOR(new BeltItem(standardProperties())),
|
||||
|
||||
;
|
||||
|
||||
// Common
|
||||
|
||||
public Item item;
|
||||
|
||||
private AllItems(Item item) {
|
||||
|
@ -71,14 +75,24 @@ public enum AllItems {
|
|||
return stack.getItem() == item;
|
||||
}
|
||||
|
||||
// Client
|
||||
|
||||
private enum AllItemRenderers {
|
||||
SYMMETRY_WAND, BUILDER_GUN,;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static ItemStackTileEntityRenderer withSpecialRenderer(String renderer) {
|
||||
if ("wand".equals(renderer))
|
||||
public static ItemStackTileEntityRenderer renderUsing(AllItemRenderers renderer) {
|
||||
switch (renderer) {
|
||||
|
||||
case SYMMETRY_WAND:
|
||||
return new SymmetryWandItemRenderer();
|
||||
if ("gun".equals(renderer))
|
||||
case BUILDER_GUN:
|
||||
return new BuilderGunItemRenderer();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
|
|
@ -1,41 +1,72 @@
|
|||
package com.simibubi.create;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.simibubi.create.foundation.packet.NbtPacket;
|
||||
import com.simibubi.create.foundation.packet.SimplePacketBase;
|
||||
import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunBeamPacket;
|
||||
import com.simibubi.create.modules.schematics.packet.ConfigureSchematicannonPacket;
|
||||
import com.simibubi.create.modules.schematics.packet.SchematicPlacePacket;
|
||||
import com.simibubi.create.modules.schematics.packet.SchematicUploadPacket;
|
||||
import com.simibubi.create.modules.symmetry.SymmetryEffectPacket;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
|
||||
public class AllPackets {
|
||||
public enum AllPackets {
|
||||
|
||||
// Client to Server
|
||||
NBT(NbtPacket.class, NbtPacket::new),
|
||||
CONFIGURE_SCHEMATICANNON(ConfigureSchematicannonPacket.class, ConfigureSchematicannonPacket::new),
|
||||
PLACE_SCHEMATIC(SchematicPlacePacket.class, SchematicPlacePacket::new),
|
||||
UPLOAD_SCHEMATIC(SchematicUploadPacket.class, SchematicUploadPacket::new),
|
||||
|
||||
// Server to Client
|
||||
SYMMETRY_EFFECT(SymmetryEffectPacket.class, SymmetryEffectPacket::new),
|
||||
BEAM_EFFECT(BuilderGunBeamPacket.class, BuilderGunBeamPacket::new),
|
||||
|
||||
;
|
||||
|
||||
public static final ResourceLocation CHANNEL_NAME = new ResourceLocation(Create.ID, "network");
|
||||
public static final String NETWORK_VERSION = new ResourceLocation(Create.ID, "1").toString();
|
||||
public static SimpleChannel channel;
|
||||
|
||||
public static void registerPackets() {
|
||||
int i = 0;
|
||||
private LoadedPacket<?> packet;
|
||||
|
||||
private <T extends SimplePacketBase> AllPackets(Class<T> type, Function<PacketBuffer, T> factory) {
|
||||
packet = new LoadedPacket<>(type, factory);
|
||||
}
|
||||
|
||||
public static void registerPackets() {
|
||||
channel = NetworkRegistry.ChannelBuilder.named(CHANNEL_NAME).serverAcceptedVersions(s -> true)
|
||||
.clientAcceptedVersions(s -> true).networkProtocolVersion(() -> NETWORK_VERSION).simpleChannel();
|
||||
|
||||
channel.messageBuilder(NbtPacket.class, i++).decoder(NbtPacket::new).encoder(NbtPacket::toBytes)
|
||||
.consumer(NbtPacket::handle).add();
|
||||
channel.messageBuilder(SchematicPlacePacket.class, i++).decoder(SchematicPlacePacket::new)
|
||||
.encoder(SchematicPlacePacket::toBytes).consumer(SchematicPlacePacket::handle).add();
|
||||
channel.messageBuilder(ConfigureSchematicannonPacket.class, i++).decoder(ConfigureSchematicannonPacket::new)
|
||||
.encoder(ConfigureSchematicannonPacket::toBytes).consumer(ConfigureSchematicannonPacket::handle).add();
|
||||
channel.messageBuilder(SchematicUploadPacket.class, i++).decoder(SchematicUploadPacket::new)
|
||||
.encoder(SchematicUploadPacket::toBytes).consumer(SchematicUploadPacket::handle).add();
|
||||
channel.messageBuilder(SymmetryEffectPacket.class, i++).decoder(SymmetryEffectPacket::new)
|
||||
.encoder(SymmetryEffectPacket::toBytes).consumer(SymmetryEffectPacket::handle).add();
|
||||
channel.messageBuilder(BuilderGunBeamPacket.class, i++).decoder(BuilderGunBeamPacket::new)
|
||||
.encoder(BuilderGunBeamPacket::toBytes).consumer(BuilderGunBeamPacket::handle).add();
|
||||
for (AllPackets packet : values())
|
||||
packet.packet.register();
|
||||
|
||||
}
|
||||
|
||||
private static class LoadedPacket<T extends SimplePacketBase> {
|
||||
private static int index = 0;
|
||||
BiConsumer<T, PacketBuffer> encoder;
|
||||
Function<PacketBuffer, T> decoder;
|
||||
BiConsumer<T, Supplier<Context>> handler;
|
||||
Class<T> type;
|
||||
|
||||
private LoadedPacket(Class<T> type, Function<PacketBuffer, T> factory) {
|
||||
encoder = T::write;
|
||||
decoder = factory;
|
||||
handler = T::handle;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private void register() {
|
||||
channel.messageBuilder(type, index++).encoder(encoder).decoder(decoder).consumer(handler).add();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.simibubi.create.modules.logistics.StockswitchTileEntity;
|
|||
import com.simibubi.create.modules.schematics.block.SchematicTableTileEntity;
|
||||
import com.simibubi.create.modules.schematics.block.SchematicannonRenderer;
|
||||
import com.simibubi.create.modules.schematics.block.SchematicannonTileEntity;
|
||||
import com.simibubi.create.modules.shopping.ShopShelfTileEntity;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
|
@ -66,6 +67,9 @@ public enum AllTileEntities {
|
|||
STOCKSWITCH(StockswitchTileEntity::new, AllBlocks.STOCKSWITCH),
|
||||
FLEXCRATE(FlexcrateTileEntity::new, AllBlocks.FLEXCRATE),
|
||||
|
||||
// Economy
|
||||
SHOP_SHELF(ShopShelfTileEntity::new, AllBlocks.SHOP_SHELF),
|
||||
|
||||
;
|
||||
|
||||
private Supplier<? extends TileEntity> supplier;
|
||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
|
||||
public class NbtPacket {
|
||||
public class NbtPacket extends SimplePacketBase {
|
||||
|
||||
public ItemStack stack;
|
||||
public int slot;
|
||||
|
@ -26,7 +26,7 @@ public class NbtPacket {
|
|||
slot = buffer.readInt();
|
||||
}
|
||||
|
||||
public void toBytes(PacketBuffer buffer) {
|
||||
public void write(PacketBuffer buffer) {
|
||||
buffer.writeItemStack(stack);
|
||||
buffer.writeInt(slot);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.simibubi.create.foundation.packet;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
|
||||
public abstract class SimplePacketBase {
|
||||
|
||||
public abstract void write(PacketBuffer buffer);
|
||||
public abstract void handle(Supplier<Context> context);
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.modules.curiosities.placementHandgun;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.simibubi.create.foundation.packet.SimplePacketBase;
|
||||
import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunHandler.LaserBeam;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -13,7 +14,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
|||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
|
||||
public class BuilderGunBeamPacket {
|
||||
public class BuilderGunBeamPacket extends SimplePacketBase {
|
||||
|
||||
public Vec3d start;
|
||||
public Vec3d target;
|
||||
|
@ -34,7 +35,7 @@ public class BuilderGunBeamPacket {
|
|||
self = buffer.readBoolean();
|
||||
}
|
||||
|
||||
public void toBytes(PacketBuffer buffer) {
|
||||
public void write(PacketBuffer buffer) {
|
||||
buffer.writeDouble(start.x);
|
||||
buffer.writeDouble(start.y);
|
||||
buffer.writeDouble(start.z);
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.minecraft.fluid.IFluidState;
|
|||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.item.UseAction;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
|
@ -82,7 +83,7 @@ public class BuilderGunItem extends InfoItem {
|
|||
}
|
||||
|
||||
public BuilderGunItem(Properties properties) {
|
||||
super(properties.maxStackSize(1));
|
||||
super(properties.maxStackSize(1).rarity(Rarity.UNCOMMON));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.modules.schematics.packet;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.simibubi.create.foundation.packet.SimplePacketBase;
|
||||
import com.simibubi.create.modules.schematics.block.SchematicannonTileEntity;
|
||||
import com.simibubi.create.modules.schematics.block.SchematicannonTileEntity.State;
|
||||
|
||||
|
@ -12,7 +13,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
|
||||
public class ConfigureSchematicannonPacket {
|
||||
public class ConfigureSchematicannonPacket extends SimplePacketBase {
|
||||
|
||||
public static enum Option {
|
||||
DONT_REPLACE, REPLACE_SOLID, REPLACE_ANY, REPLACE_EMPTY, SKIP_MISSING, SKIP_TILES, PLAY, PAUSE, STOP;
|
||||
|
@ -39,7 +40,7 @@ public class ConfigureSchematicannonPacket {
|
|||
set = buffer.readBoolean();
|
||||
}
|
||||
|
||||
public void toBytes(PacketBuffer buffer) {
|
||||
public void write(PacketBuffer buffer) {
|
||||
buffer.writeBlockPos(pos);
|
||||
buffer.writeInt(option.ordinal());
|
||||
buffer.writeBoolean(set);
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.modules.schematics.packet;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.simibubi.create.foundation.packet.SimplePacketBase;
|
||||
import com.simibubi.create.modules.schematics.item.BlueprintItem;
|
||||
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
|
@ -11,7 +12,7 @@ import net.minecraft.network.PacketBuffer;
|
|||
import net.minecraft.world.gen.feature.template.Template;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
|
||||
public class SchematicPlacePacket {
|
||||
public class SchematicPlacePacket extends SimplePacketBase {
|
||||
|
||||
public ItemStack stack;
|
||||
|
||||
|
@ -23,7 +24,7 @@ public class SchematicPlacePacket {
|
|||
stack = buffer.readItemStack();
|
||||
}
|
||||
|
||||
public void toBytes(PacketBuffer buffer) {
|
||||
public void write(PacketBuffer buffer) {
|
||||
buffer.writeItemStack(stack);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.modules.schematics.packet;
|
|||
import java.util.function.Supplier;
|
||||
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.packet.SimplePacketBase;
|
||||
import com.simibubi.create.foundation.type.DimensionPos;
|
||||
import com.simibubi.create.modules.schematics.block.SchematicTableContainer;
|
||||
|
||||
|
@ -11,7 +12,7 @@ import net.minecraft.network.PacketBuffer;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
|
||||
public class SchematicUploadPacket {
|
||||
public class SchematicUploadPacket extends SimplePacketBase {
|
||||
|
||||
public static final int BEGIN = 0;
|
||||
public static final int WRITE = 1;
|
||||
|
@ -53,7 +54,7 @@ public class SchematicUploadPacket {
|
|||
data = buffer.readByteArray();
|
||||
}
|
||||
|
||||
public void toBytes(PacketBuffer buffer) {
|
||||
public void write(PacketBuffer buffer) {
|
||||
buffer.writeInt(code);
|
||||
buffer.writeString(schematic);
|
||||
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
package com.simibubi.create.modules.shopping;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.StateContainer.Builder;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
public class ShopShelfBlock extends HorizontalBlock {
|
||||
|
||||
public static final VoxelShape TOP_SHAPE = makeCuboidShape(0, 14, 0, 16, 16, 16);
|
||||
|
||||
public static final VoxelShape BODY_SOUTH_SHAPE = makeCuboidShape(0, 0, 0, 16, 14, 14);
|
||||
public static final VoxelShape BODY_NORTH_SHAPE = makeCuboidShape(0, 0, 2, 16, 14, 16);
|
||||
public static final VoxelShape BODY_EAST_SHAPE = makeCuboidShape(0, 0, 0, 14, 14, 16);
|
||||
public static final VoxelShape BODY_WEST_SHAPE = makeCuboidShape(2, 0, 0, 16, 14, 16);
|
||||
|
||||
public ShopShelfBlock() {
|
||||
super(Properties.from(Blocks.SPRUCE_PLANKS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return new ShopShelfTileEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
|
||||
ShopShelfTileEntity te = (ShopShelfTileEntity) worldIn.getTileEntity(pos);
|
||||
te.setOwner(placer.getUniqueID());
|
||||
worldIn.notifyBlockUpdate(pos, state, state, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||
BlockRayTraceResult hit) {
|
||||
ShopShelfTileEntity te = (ShopShelfTileEntity) worldIn.getTileEntity(pos);
|
||||
if (te == null)
|
||||
return false;
|
||||
if (!worldIn.isRemote)
|
||||
NetworkHooks.openGui((ServerPlayerEntity) player, te, te::sendToContainer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||
builder.add(HORIZONTAL_FACING);
|
||||
super.fillStateContainer(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
VoxelShape body = VoxelShapes.empty();
|
||||
switch (state.get(HORIZONTAL_FACING)) {
|
||||
case EAST:
|
||||
body = BODY_EAST_SHAPE;
|
||||
break;
|
||||
case NORTH:
|
||||
body = BODY_NORTH_SHAPE;
|
||||
break;
|
||||
case SOUTH:
|
||||
body = BODY_SOUTH_SHAPE;
|
||||
break;
|
||||
case WEST:
|
||||
body = BODY_WEST_SHAPE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return VoxelShapes.or(TOP_SHAPE, body);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.simibubi.create.modules.shopping;
|
||||
|
||||
import com.simibubi.create.AllContainers;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
public class ShopShelfContainer extends Container {
|
||||
|
||||
public ShopShelfContainer(int id, PlayerInventory inv, ShopShelfTileEntity te) {
|
||||
super(AllContainers.ShopShelf.type, id);
|
||||
}
|
||||
|
||||
public ShopShelfContainer(int id, PlayerInventory inv, PacketBuffer extraData) {
|
||||
super(AllContainers.ShopShelf.type, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(PlayerEntity playerIn) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.simibubi.create.modules.shopping;
|
||||
|
||||
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class ShopShelfScreen extends AbstractSimiContainerScreen<ShopShelfContainer> {
|
||||
|
||||
public ShopShelfScreen(ShopShelfContainer container, PlayerInventory inv, ITextComponent title) {
|
||||
super(container, inv, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderWindow(int mouseX, int mouseY, float partialTicks) {
|
||||
renderTooltip("Hi", mouseX, mouseY);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.simibubi.create.modules.shopping;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.foundation.block.SyncedTileEntity;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
|
||||
public class ShopShelfTileEntity extends SyncedTileEntity implements INamedContainerProvider {
|
||||
|
||||
private UUID owner;
|
||||
|
||||
public ShopShelfTileEntity() {
|
||||
super(AllTileEntities.ShopShelfTileEntity.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT compound) {
|
||||
if (compound.contains("Owner"))
|
||||
setOwner(NBTUtil.readUniqueId(compound.getCompound("Owner")));
|
||||
super.read(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT compound) {
|
||||
if (getOwner() != null)
|
||||
compound.put("Owner", NBTUtil.writeUniqueId(getOwner()));
|
||||
return super.write(compound);
|
||||
}
|
||||
|
||||
public UUID getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(UUID owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public void sendToContainer(PacketBuffer buffer) {
|
||||
buffer.writeUniqueId(getOwner());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container createMenu(int id, PlayerInventory inventory, PlayerEntity player) {
|
||||
return new ShopShelfContainer(id, inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return new StringTextComponent(getType().getRegistryName().toString());
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.simibubi.create.foundation.packet.SimplePacketBase;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -12,7 +14,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
|||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
|
||||
public class SymmetryEffectPacket {
|
||||
public class SymmetryEffectPacket extends SimplePacketBase {
|
||||
|
||||
private BlockPos mirror;
|
||||
private List<BlockPos> positions;
|
||||
|
@ -31,7 +33,7 @@ public class SymmetryEffectPacket {
|
|||
}
|
||||
}
|
||||
|
||||
public void toBytes(PacketBuffer buffer) {
|
||||
public void write(PacketBuffer buffer) {
|
||||
buffer.writeBlockPos(mirror);
|
||||
buffer.writeInt(positions.size());
|
||||
for (BlockPos blockPos : positions) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
|
@ -46,7 +47,7 @@ public class SymmetryWandItem extends InfoItem {
|
|||
private static final String $ENABLE = "enable";
|
||||
|
||||
public SymmetryWandItem(Properties properties) {
|
||||
super(properties.maxStackSize(1));
|
||||
super(properties.maxStackSize(1).rarity(Rarity.UNCOMMON));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
12
src/main/resources/assets/create/blockstates/shop_shelf.json
Normal file
12
src/main/resources/assets/create/blockstates/shop_shelf.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"forgemarker": 1,
|
||||
"defaults": {
|
||||
"model": "create:block/shop_shelf"
|
||||
},
|
||||
"variants": {
|
||||
"facing=north": { "model": "create:block/shop_shelf", "y": 180 },
|
||||
"facing=south": { "model": "create:block/shop_shelf" },
|
||||
"facing=east": { "model": "create:block/shop_shelf", "y": 270 },
|
||||
"facing=west": { "model": "create:block/shop_shelf", "y": 90 }
|
||||
}
|
||||
}
|
|
@ -66,6 +66,8 @@
|
|||
|
||||
"block.create.cocoa_log": "Cocoa Jungle Log",
|
||||
|
||||
"block.create.shop_shelf": "Shelf",
|
||||
|
||||
"death.attack.create.crush": "%1$s was crushed by a dangerous contraption",
|
||||
|
||||
"itemGroup.create": "Create"
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
{
|
||||
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
|
||||
"parent": "block/cube",
|
||||
"textures": {
|
||||
"particle": "block/stripped_spruce_log",
|
||||
"0": "block/stripped_spruce_log_top",
|
||||
"1": "block/stripped_spruce_log",
|
||||
"2": "block/dark_oak_planks",
|
||||
"3": "block/spruce_planks",
|
||||
"4": "block/andesite"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"name": "Body",
|
||||
"from": [ 0.0, 0.0, 0.0 ],
|
||||
"to": [ 16.0, 14.0, 14.0 ],
|
||||
"faces": {
|
||||
"north": { "texture": "#0", "uv": [ 0.0, 1.0, 16.0, 15.0 ] },
|
||||
"east": { "texture": "#1", "uv": [ 1.0, 1.0, 15.0, 15.0 ] },
|
||||
"south": { "texture": "#0", "uv": [ 0.0, 1.0, 16.0, 15.0 ] },
|
||||
"west": { "texture": "#1", "uv": [ 1.0, 1.0, 15.0, 15.0 ] },
|
||||
"down": { "texture": "#0", "uv": [ 0.0, 1.0, 16.0, 15.0 ] }
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Top",
|
||||
"from": [ 0.0, 14.0, 0.0 ],
|
||||
"to": [ 16.0, 16.0, 15.0 ],
|
||||
"faces": {
|
||||
"north": { "texture": "#2", "uv": [ 0.0, 6.0, 16.0, 8.0 ] },
|
||||
"east": { "texture": "#2", "uv": [ 1.0, 6.0, 16.0, 8.0 ] },
|
||||
"south": { "texture": "#2", "uv": [ 0.0, 6.0, 16.0, 8.0 ] },
|
||||
"west": { "texture": "#2", "uv": [ 1.0, 6.0, 16.0, 8.0 ] },
|
||||
"up": { "texture": "#2", "uv": [ 0.0, 0.0, 16.0, 15.0 ] },
|
||||
"down": { "texture": "#2", "uv": [ 0.0, 1.0, 16.0, 16.0 ], "rotation": 180 }
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Drawer Body",
|
||||
"from": [ 1.0, 8.0, 8.0 ],
|
||||
"to": [ 15.0, 13.0, 15.0 ],
|
||||
"faces": {
|
||||
"north": { "texture": "#3", "uv": [ 1.0, 3.0, 15.0, 8.0 ] },
|
||||
"east": { "texture": "#3", "uv": [ 7.0, 3.0, 14.0, 8.0 ] },
|
||||
"south": { "texture": "#3", "uv": [ 1.0, 7.0, 15.0, 12.0 ] },
|
||||
"west": { "texture": "#3", "uv": [ 1.0, 3.0, 8.0, 8.0 ] },
|
||||
"up": { "texture": "#3", "uv": [ 1.0, 5.0, 15.0, 12.0 ] },
|
||||
"down": { "texture": "#3", "uv": [ 1.0, 3.0, 15.0, 10.0 ] }
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Drawer Knob",
|
||||
"from": [ 6.0, 11.0, 14.5 ],
|
||||
"to": [ 10.0, 12.0, 15.5 ],
|
||||
"faces": {
|
||||
"north": { "texture": "#4", "uv": [ 6.0, 6.0, 10.0, 7.0 ] },
|
||||
"east": { "texture": "#4", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
|
||||
"south": { "texture": "#4", "uv": [ 6.0, 7.0, 10.0, 8.0 ] },
|
||||
"west": { "texture": "#4", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
|
||||
"up": { "texture": "#4", "uv": [ 4.0, 3.0, 8.0, 4.0 ] },
|
||||
"down": { "texture": "#4", "uv": [ 6.0, 2.0, 10.0, 3.0 ] }
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Another Drawer Body",
|
||||
"from": [ 1.0, 2.0, 8.0 ],
|
||||
"to": [ 15.0, 7.0, 15.0 ],
|
||||
"faces": {
|
||||
"north": { "texture": "#3", "uv": [ 1.0, 0.0, 15.0, 5.0 ] },
|
||||
"east": { "texture": "#3", "uv": [ 7.0, 3.0, 14.0, 8.0 ] },
|
||||
"south": { "texture": "#3", "uv": [ 1.0, 7.0, 15.0, 12.0 ] },
|
||||
"west": { "texture": "#3", "uv": [ 1.0, 3.0, 8.0, 8.0 ] },
|
||||
"up": { "texture": "#3", "uv": [ 1.0, 1.0, 15.0, 8.0 ] },
|
||||
"down": { "texture": "#3", "uv": [ 1.0, 3.0, 15.0, 10.0 ] }
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Another Drawer Knob",
|
||||
"from": [ 6.0, 5.0, 14.5 ],
|
||||
"to": [ 10.0, 6.0, 15.5 ],
|
||||
"faces": {
|
||||
"north": { "texture": "#4", "uv": [ 6.0, 6.0, 10.0, 7.0 ] },
|
||||
"east": { "texture": "#4", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
|
||||
"south": { "texture": "#4", "uv": [ 6.0, 7.0, 10.0, 8.0 ] },
|
||||
"west": { "texture": "#4", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
|
||||
"up": { "texture": "#4", "uv": [ 4.0, 3.0, 8.0, 4.0 ] },
|
||||
"down": { "texture": "#4", "uv": [ 6.0, 2.0, 10.0, 3.0 ] }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "create:block/shop_shelf"
|
||||
}
|
Loading…
Reference in a new issue