diff --git a/build.gradle b/build.gradle index afa76c8a1..ca34bd323 100644 --- a/build.gradle +++ b/build.gradle @@ -13,14 +13,14 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = 'mc1.14.4_v0.1.1' +version = 'mc1.14.4_v0.1.1a' group = 'com.simibubi.create' archivesBaseName = 'create' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' minecraft { - mappings channel: 'snapshot', version: '20190917-1.14.3' + mappings channel: 'snapshot', version: '20191012-1.14.3' runs { client { @@ -71,12 +71,12 @@ repositories { } dependencies { - minecraft 'net.minecraftforge:forge:1.14.4-28.1.6' + minecraft 'net.minecraftforge:forge:1.14.4-28.1.45' // compile against the JEI API but do not include it at runtime - compileOnly fg.deobf("mezz.jei:jei-1.14.4:6.0.0.10:api") + compileOnly fg.deobf("mezz.jei:jei-1.14.4:6.0.0.18:api") // at runtime, use the full JEI jar - runtimeOnly fg.deobf("mezz.jei:jei-1.14.4:6.0.0.10") + //runtimeOnly fg.deobf("mezz.jei:jei-1.14.4:6.0.0.18") } jar { diff --git a/src/main/java/com/simibubi/create/AllBlockTags.java b/src/main/java/com/simibubi/create/AllBlockTags.java index 5b2925c7e..94a42df87 100644 --- a/src/main/java/com/simibubi/create/AllBlockTags.java +++ b/src/main/java/com/simibubi/create/AllBlockTags.java @@ -1,5 +1,7 @@ package com.simibubi.create; +import com.simibubi.create.foundation.utility.Lang; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.tags.BlockTags; @@ -8,10 +10,8 @@ import net.minecraft.util.ResourceLocation; public enum AllBlockTags { - WINDMILL_SAILS, - FAN_HEATERS, - WINDOWABLE, - + WINDMILL_SAILS, FAN_HEATERS, WINDOWABLE, + ; public Tag tag; @@ -22,9 +22,9 @@ public enum AllBlockTags { private AllBlockTags(String path) { tag = new BlockTags.Wrapper( - new ResourceLocation(Create.ID, (path.isEmpty() ? "" : path + "/") + name().toLowerCase())); + new ResourceLocation(Create.ID, (path.isEmpty() ? "" : path + "/") + Lang.asId(name()))); } - + public boolean matches(BlockState block) { return tag.contains(block.getBlock()); } diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index b5864318a..aa30de544 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -5,6 +5,7 @@ import com.simibubi.create.foundation.block.IWithoutBlockItem; import com.simibubi.create.foundation.block.ProperStairsBlock; import com.simibubi.create.foundation.block.RenderUtilityAxisBlock; import com.simibubi.create.foundation.block.RenderUtilityBlock; +import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.IModule; import com.simibubi.create.modules.contraptions.generators.MotorBlock; import com.simibubi.create.modules.contraptions.generators.WaterWheelBlock; @@ -182,14 +183,14 @@ public enum AllBlocks { CategoryTracker.currentModule = new IModule() { @Override public String getModuleName() { - return name().toLowerCase().replaceAll("__", ""); + return Lang.asId(name()).replaceAll("__", ""); } }; } private AllBlocks(Block block, ComesWith... comesWith) { this.block = block; - this.block.setRegistryName(Create.ID, this.name().toLowerCase()); + this.block.setRegistryName(Create.ID, Lang.asId(name())); this.module = CategoryTracker.currentModule; alsoRegistered = new Block[comesWith.length]; @@ -259,7 +260,7 @@ public enum AllBlocks { } return featured.setRegistryName(Create.ID, - block.getRegistryName().getPath() + "_" + feature.name().toLowerCase()); + block.getRegistryName().getPath() + "_" + Lang.asId(feature.name())); } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/com/simibubi/create/AllContainers.java b/src/main/java/com/simibubi/create/AllContainers.java index fb0153905..0f6113487 100644 --- a/src/main/java/com/simibubi/create/AllContainers.java +++ b/src/main/java/com/simibubi/create/AllContainers.java @@ -1,5 +1,6 @@ package com.simibubi.create; +import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.logistics.block.FlexcrateContainer; import com.simibubi.create.modules.logistics.block.FlexcrateScreen; import com.simibubi.create.modules.schematics.block.SchematicTableContainer; @@ -17,19 +18,15 @@ import net.minecraft.inventory.container.ContainerType.IFactory; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; import net.minecraftforge.fml.network.IContainerFactory; +import net.minecraftforge.registries.IForgeRegistry; -@EventBusSubscriber(bus = Bus.MOD) public enum AllContainers { - SCHEMATIC_TABLE(SchematicTableContainer::new), + SCHEMATIC_TABLE(SchematicTableContainer::new), SCHEMATICANNON(SchematicannonContainer::new), FLEXCRATE(FlexcrateContainer::new), - + ; public ContainerType type; @@ -39,13 +36,11 @@ public enum AllContainers { this.factory = factory; } - @SubscribeEvent - public static void onContainerTypeRegistry(final RegistryEvent.Register> e) { - + public static void registerContainers(IForgeRegistry> iForgeRegistry) { for (AllContainers container : values()) { container.type = new ContainerType<>(container.factory) - .setRegistryName(new ResourceLocation(Create.ID, container.name().toLowerCase())); - e.getRegistry().register(container.type); + .setRegistryName(new ResourceLocation(Create.ID, Lang.asId(container.name()))); + iForgeRegistry.register(container.type); } } @@ -58,7 +53,8 @@ public enum AllContainers { @OnlyIn(Dist.CLIENT) @SuppressWarnings("unchecked") - private static > void bind(AllContainers c, IScreenFactory factory) { + private static > void bind(AllContainers c, + IScreenFactory factory) { ScreenManager.registerFactory((ContainerType) c.type, factory); } diff --git a/src/main/java/com/simibubi/create/AllItemTags.java b/src/main/java/com/simibubi/create/AllItemTags.java index b8eaa1b7a..77dab7504 100644 --- a/src/main/java/com/simibubi/create/AllItemTags.java +++ b/src/main/java/com/simibubi/create/AllItemTags.java @@ -1,5 +1,7 @@ package com.simibubi.create; +import com.simibubi.create.foundation.utility.Lang; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tags.ItemTags; @@ -13,11 +15,11 @@ public enum AllItemTags { public Tag tag; private AllItemTags(String path) { - tag = new ItemTags.Wrapper(new ResourceLocation(Create.ID, path + "/" + name().toLowerCase())); + tag = new ItemTags.Wrapper(new ResourceLocation(Create.ID, path + "/" + Lang.asId(name()))); } public boolean matches(ItemStack item) { return tag.contains(item.getItem()); } - + } diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index 57502af0a..8b3bee9e3 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -1,6 +1,7 @@ package com.simibubi.create; import com.simibubi.create.foundation.item.IItemWithColorHandler; +import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.IModule; import com.simibubi.create.modules.contraptions.relays.VerticalGearboxItem; import com.simibubi.create.modules.contraptions.relays.belt.BeltItem; @@ -91,14 +92,14 @@ public enum AllItems { CategoryTracker.currentModule = new IModule() { @Override public String getModuleName() { - return name().toLowerCase().replaceAll("__", ""); + return Lang.asId(name()).replaceAll("__", ""); } }; } private AllItems(Item item) { this.item = item; - this.item.setRegistryName(Create.ID, this.name().toLowerCase()); + this.item.setRegistryName(Create.ID, Lang.asId(name())); this.module = CategoryTracker.currentModule; } diff --git a/src/main/java/com/simibubi/create/AllRecipes.java b/src/main/java/com/simibubi/create/AllRecipes.java index 6757954aa..659f6321f 100644 --- a/src/main/java/com/simibubi/create/AllRecipes.java +++ b/src/main/java/com/simibubi/create/AllRecipes.java @@ -2,6 +2,7 @@ package com.simibubi.create; import java.util.function.Supplier; +import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.contraptions.base.ProcessingRecipeSerializer; import com.simibubi.create.modules.contraptions.receivers.CrushingRecipe; import com.simibubi.create.modules.contraptions.receivers.PressingRecipe; @@ -52,7 +53,7 @@ public enum AllRecipes { public static void register(RegistryEvent.Register> event) { for (AllRecipes r : AllRecipes.values()) { r.serializer = r.supplier.get(); - ResourceLocation location = new ResourceLocation(Create.ID, r.name().toLowerCase()); + ResourceLocation location = new ResourceLocation(Create.ID, Lang.asId(r.name())); event.getRegistry().register(r.serializer.setRegistryName(location)); } } diff --git a/src/main/java/com/simibubi/create/AllTileEntities.java b/src/main/java/com/simibubi/create/AllTileEntities.java index 966e1955e..5beacae39 100644 --- a/src/main/java/com/simibubi/create/AllTileEntities.java +++ b/src/main/java/com/simibubi/create/AllTileEntities.java @@ -2,6 +2,7 @@ package com.simibubi.create; import java.util.function.Supplier; +import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.modules.contraptions.generators.MotorTileEntity; import com.simibubi.create.modules.contraptions.generators.MotorTileEntityRenderer; @@ -54,13 +55,9 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.client.registry.ClientRegistry; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; +import net.minecraftforge.registries.IForgeRegistry; -@Mod.EventBusSubscriber(bus = Bus.MOD) public enum AllTileEntities { // Schematics @@ -95,7 +92,7 @@ public enum AllTileEntities { BELT_FUNNEL(BeltFunnelTileEntity::new, AllBlocks.BELT_FUNNEL), ENTITY_DETECTOR(EntityDetectorTileEntity::new, AllBlocks.ENTITY_DETECTOR), FLEXPEATER(FlexpeaterTileEntity::new, AllBlocks.FLEXPEATER), - + // Curiosities WINDOW_IN_A_BLOCK(WindowInABlockTileEntity::new, AllBlocks.WINDOW_IN_A_BLOCK), @@ -110,18 +107,16 @@ public enum AllTileEntities { this.blocks = blocks; } - @SubscribeEvent - public static void onTileEntityRegistry(final RegistryEvent.Register> event) { - + public static void registerTileEntities(IForgeRegistry> registry) { for (AllTileEntities tileEntity : values()) { Block[] blocks = new Block[tileEntity.blocks.length]; for (int i = 0; i < blocks.length; i++) blocks[i] = tileEntity.blocks[i].block; - ResourceLocation resourceLocation = new ResourceLocation(Create.ID, tileEntity.name().toLowerCase()); + ResourceLocation resourceLocation = new ResourceLocation(Create.ID, Lang.asId(tileEntity.name())); tileEntity.type = TileEntityType.Builder.create(tileEntity.supplier, blocks).build(null) .setRegistryName(resourceLocation); - event.getRegistry().register(tileEntity.type); + registry.register(tileEntity.type); } } diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index 6fdf530b7..6ad1204b6 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -9,20 +9,20 @@ import com.simibubi.create.modules.logistics.FrequencyHandler; import com.simibubi.create.modules.schematics.ServerSchematicLoader; import net.minecraft.block.Block; +import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -@EventBusSubscriber(bus = Bus.MOD) @Mod(Create.ID) public class Create { @@ -39,11 +39,20 @@ public class Create { public static ModConfig config; public Create() { + IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + modEventBus.addListener(Create::init); + modEventBus.addGenericListener(Block.class, Create::registerBlocks); + modEventBus.addGenericListener(Item.class, Create::registerItems); + modEventBus.addGenericListener(IRecipeSerializer.class, Create::registerRecipes); + modEventBus.addGenericListener(TileEntityType.class, Create::registerTileEntities); + modEventBus.addGenericListener(ContainerType.class, Create::registerContainers); + modEventBus.addListener(Create::createConfigs); + CreateClient.addListeners(modEventBus); + ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, CreateConfig.specification); ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, CreateClientConfig.specification); } - @SubscribeEvent public static void init(final FMLCommonSetupEvent event) { schematicReceiver = new ServerSchematicLoader(); frequencyHandler = new FrequencyHandler(); @@ -52,23 +61,27 @@ public class Create { AllPackets.registerPackets(); } - @SubscribeEvent public static void registerItems(RegistryEvent.Register event) { AllItems.registerItems(event.getRegistry()); AllBlocks.registerItemBlocks(event.getRegistry()); } - @SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { AllBlocks.registerBlocks(event.getRegistry()); } - @SubscribeEvent + public static void registerTileEntities(RegistryEvent.Register> event) { + AllTileEntities.registerTileEntities(event.getRegistry()); + } + + public static void registerContainers(RegistryEvent.Register> event) { + AllContainers.registerContainers(event.getRegistry()); + } + public static void registerRecipes(RegistryEvent.Register> event) { AllRecipes.register(event); } - @SubscribeEvent public static void createConfigs(ModConfig.ModConfigEvent event) { if (event.getConfig().getSpec() == CreateClientConfig.specification) return; diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 1b1323e44..13f29c9b6 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -24,13 +24,11 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.ModelBakeEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -@EventBusSubscriber(bus = Bus.MOD) public class CreateClient { public static ClientSchematicLoader schematicSender; @@ -41,7 +39,14 @@ public class CreateClient { public static ModConfig config; - @SubscribeEvent + public static void addListeners(IEventBus modEventBus) { + DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { + modEventBus.addListener(CreateClient::clientInit); + modEventBus.addListener(CreateClient::createConfigs); + modEventBus.addListener(CreateClient::onModelBake); + }); + } + public static void clientInit(FMLClientSetupEvent event) { schematicSender = new ClientSchematicLoader(); schematicHandler = new SchematicHandler(); @@ -60,7 +65,6 @@ public class CreateClient { ((IReloadableResourceManager) resourceManager).addReloadListener(new CachedBufferReloader()); } - @SubscribeEvent public static void createConfigs(ModConfig.ModConfigEvent event) { if (event.getConfig().getSpec() == CreateConfig.specification) return; @@ -75,7 +79,6 @@ public class CreateClient { schematicHologram.tick(); } - @SubscribeEvent @OnlyIn(Dist.CLIENT) public static void onModelBake(ModelBakeEvent event) { Map modelRegistry = event.getModelRegistry(); @@ -111,4 +114,6 @@ public class CreateClient { modelRegistry.put(location, factory.apply(modelRegistry.get(location))); } + + } diff --git a/src/main/java/com/simibubi/create/ScreenResources.java b/src/main/java/com/simibubi/create/ScreenResources.java index ede2380d6..6c4ba4e7b 100644 --- a/src/main/java/com/simibubi/create/ScreenResources.java +++ b/src/main/java/com/simibubi/create/ScreenResources.java @@ -38,6 +38,7 @@ public enum ScreenResources { BLOCKZAPPER_UPGRADE_RECIPE("recipes2.png", 144, 66), PRESSER_RECIPE("recipes2.png", 0, 108, 177, 109), WASHING_RECIPE("recipes3.png", 177, 109), + PROCESSING_RECIPE_SLOT("recipes3.png", 177, 0, 20, 20), // Widgets PALETTE_BUTTON("palette_picker.png", 0, 236, 20, 20), diff --git a/src/main/java/com/simibubi/create/compat/jei/BlockzapperUpgradeCategory.java b/src/main/java/com/simibubi/create/compat/jei/BlockzapperUpgradeCategory.java index a0516c980..50ab29658 100644 --- a/src/main/java/com/simibubi/create/compat/jei/BlockzapperUpgradeCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/BlockzapperUpgradeCategory.java @@ -109,7 +109,7 @@ public class BlockzapperUpgradeCategory implements IRecipeCategory private static ResourceLocation ID = new ResourceLocation(Create.ID, "splashing"); private IDrawable icon; + private IDrawable slot; public SplashingCategory() { + slot = new ScreenResourceWrapper(ScreenResources.PROCESSING_RECIPE_SLOT); icon = new DoubleItemIcon(() -> new ItemStack(AllItems.PROPELLER.get()), () -> new ItemStack(Items.WATER_BUCKET)); } - + @Override public IDrawable getIcon() { return icon; @@ -54,7 +56,7 @@ public class SplashingCategory extends ProcessingViaFanCategory public String getTitle() { return Lang.translate("recipe.splashing"); } - + @Override public void setIngredients(SplashingRecipe recipe, IIngredients ingredients) { ingredients.setInputIngredients(recipe.getIngredients()); @@ -69,7 +71,10 @@ public class SplashingCategory extends ProcessingViaFanCategory List results = recipe.getRollableResults(); for (int outputIndex = 0; outputIndex < results.size(); outputIndex++) { - itemStacks.init(outputIndex + 1, false, 139, 58 + 19 * outputIndex); + int xOffset = outputIndex % 2 == 0 ? 0 : 19; + int yOffset = (outputIndex / 2) * -19; + + itemStacks.init(outputIndex + 1, false, 132 + xOffset, 77 + yOffset); itemStacks.set(outputIndex + 1, results.get(outputIndex).getStack()); } @@ -88,6 +93,17 @@ public class SplashingCategory extends ProcessingViaFanCategory return new ScreenResourceWrapper(ScreenResources.WASHING_RECIPE); } + @Override + public void draw(SplashingRecipe recipe, double mouseX, double mouseY) { + super.draw(recipe, mouseX, mouseY); + int size = recipe.getPossibleOutputs().size(); + for (int i = 4; i < size; i++) { + int xOffset = i % 2 == 0 ? 0 : 19; + int yOffset = (i / 2) * -19; + slot.draw(131 + xOffset, 76 + yOffset); + } + } + @Override public void renderAttachedBlock() { BlockState state = Blocks.WATER.getDefaultState().with(FlowingFluidBlock.LEVEL, 8); diff --git a/src/main/java/com/simibubi/create/foundation/block/ProperStairsBlock.java b/src/main/java/com/simibubi/create/foundation/block/ProperStairsBlock.java index 5efbf5045..35892d1fd 100644 --- a/src/main/java/com/simibubi/create/foundation/block/ProperStairsBlock.java +++ b/src/main/java/com/simibubi/create/foundation/block/ProperStairsBlock.java @@ -6,7 +6,7 @@ import net.minecraft.block.StairsBlock; public class ProperStairsBlock extends StairsBlock { public ProperStairsBlock(Block block) { - super(block.getDefaultState(), Properties.from(block)); + super(() -> block.getDefaultState(), Properties.from(block)); } } diff --git a/src/main/java/com/simibubi/create/foundation/packet/NbtPacket.java b/src/main/java/com/simibubi/create/foundation/packet/NbtPacket.java index 26875bc49..490326f10 100644 --- a/src/main/java/com/simibubi/create/foundation/packet/NbtPacket.java +++ b/src/main/java/com/simibubi/create/foundation/packet/NbtPacket.java @@ -5,30 +5,36 @@ import java.util.function.Supplier; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; +import net.minecraft.util.Hand; import net.minecraftforge.fml.network.NetworkEvent.Context; public class NbtPacket extends SimplePacketBase { public ItemStack stack; public int slot; + public Hand hand; - public NbtPacket(ItemStack stack) { + public NbtPacket(ItemStack stack, Hand hand) { this(stack, -1); + this.hand = hand; } public NbtPacket(ItemStack stack, int slot) { this.stack = stack; this.slot = slot; + this.hand = Hand.MAIN_HAND; } public NbtPacket(PacketBuffer buffer) { stack = buffer.readItemStack(); slot = buffer.readInt(); + hand = Hand.values()[buffer.readInt()]; } public void write(PacketBuffer buffer) { buffer.writeItemStack(stack); buffer.writeInt(slot); + buffer.writeInt(hand.ordinal()); } public void handle(Supplier context) { @@ -36,15 +42,7 @@ public class NbtPacket extends SimplePacketBase { ServerPlayerEntity player = context.get().getSender(); if (slot == -1) { - ItemStack heldItem = player.getHeldItemMainhand(); - if (heldItem.getItem() == stack.getItem()) { - heldItem.setTag(stack.getTag()); - } - return; - } - - if (slot == -2) { - ItemStack heldItem = player.getHeldItemOffhand(); + ItemStack heldItem = player.getHeldItem(hand); if (heldItem.getItem() == stack.getItem()) { heldItem.setTag(stack.getTag()); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/FilesHelper.java b/src/main/java/com/simibubi/create/foundation/utility/FilesHelper.java index 2ab097e60..6e41a84e5 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/FilesHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/FilesHelper.java @@ -26,7 +26,7 @@ public class FilesHelper { Path path = Paths.get(name); if (path.getParent() != null) createFolderIfMissing(path.getParent().toString()); - + if (!Files.isDirectory(path)) { try { Files.createDirectory(path); @@ -49,7 +49,7 @@ public class FilesHelper { } public static String slug(String name) { - return name.toLowerCase().replace(' ', '_').replace('!', '_').replace('?', '_'); + return Lang.asId(name).replace(' ', '_').replace('!', '_').replace('?', '_'); } public static boolean saveTagCompoundAsJson(CompoundNBT compound, String path) { @@ -65,7 +65,6 @@ public class FilesHelper { } return false; } - public static boolean saveTagCompoundAsJsonCompact(CompoundNBT compound, String path) { try { @@ -78,7 +77,7 @@ public class FilesHelper { e.printStackTrace(); } return false; - + } public static CompoundNBT loadJsonNBT(InputStream inputStream) { @@ -110,5 +109,4 @@ public class FilesHelper { return null; } - } diff --git a/src/main/java/com/simibubi/create/foundation/utility/ItemDescription.java b/src/main/java/com/simibubi/create/foundation/utility/ItemDescription.java index 83002860f..99145c52b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ItemDescription.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ItemDescription.java @@ -85,19 +85,41 @@ public class ItemDescription { boolean hasControls = !linesOnCtrl.isEmpty(); if (hasDescription || hasControls) { + String[] holdKey = Lang.translate("tooltip.holdKey", "$").split("\\$"); + String[] holdKeyOrKey = Lang.translate("tooltip.holdKeyOrKey", "$", "$").split("\\$"); + String keyShift = Lang.translate("tooltip.keyShift"); + String keyCtrl = Lang.translate("tooltip.keyCtrl"); for (List list : Arrays.asList(lines, linesOnShift, linesOnCtrl)) { boolean shift = list == linesOnShift; boolean ctrl = list == linesOnCtrl; - String tabs = DARK_GRAY + "Hold "; - if (hasDescription) - tabs += "<" + (shift ? palette.hColor : palette.color) + "Shift" + DARK_GRAY + ">"; - if (hasDescription && hasControls) - tabs += " or "; - if (hasControls) - tabs += "<" + (ctrl ? palette.hColor : palette.color) + "Control" + DARK_GRAY + ">"; + if (holdKey.length != 2 || holdKeyOrKey.length != 3) { + list.add(0, new StringTextComponent("Invalid lang formatting!")); + continue; + } - list.add(0, new StringTextComponent(tabs)); + StringBuilder tabBuilder = new StringBuilder(); + tabBuilder.append(DARK_GRAY); + if (hasDescription && hasControls) { + tabBuilder.append(holdKeyOrKey[0]); + tabBuilder.append(shift ? palette.hColor : palette.color); + tabBuilder.append(keyShift); + tabBuilder.append(DARK_GRAY); + tabBuilder.append(holdKeyOrKey[1]); + tabBuilder.append(ctrl ? palette.hColor : palette.color); + tabBuilder.append(keyCtrl); + tabBuilder.append(DARK_GRAY); + tabBuilder.append(holdKeyOrKey[2]); + + } else { + tabBuilder.append(holdKey[0]); + tabBuilder.append((hasDescription ? shift : ctrl) ? palette.hColor : palette.color); + tabBuilder.append(hasDescription ? keyShift : keyCtrl); + tabBuilder.append(DARK_GRAY); + tabBuilder.append(holdKey[1]); + } + + list.add(0, new StringTextComponent(tabBuilder.toString())); if (shift || ctrl) list.add(1, new StringTextComponent("")); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/Lang.java b/src/main/java/com/simibubi/create/foundation/utility/Lang.java index a095dafb7..a763c5ced 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Lang.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Lang.java @@ -2,6 +2,7 @@ package com.simibubi.create.foundation.utility; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import com.simibubi.create.Create; @@ -30,4 +31,8 @@ public class Lang { return result; } + public static String asId(String name) { + return name.toLowerCase(Locale.ENGLISH); + } + } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/receivers/constructs/AbstractChassisBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/receivers/constructs/AbstractChassisBlock.java index fb5fa52c6..2482b51e1 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/receivers/constructs/AbstractChassisBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/receivers/constructs/AbstractChassisBlock.java @@ -4,25 +4,30 @@ import com.simibubi.create.foundation.block.IBlockWithScrollableValue; import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.utility.Lang; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.RotatedPillarBlock; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.particles.ParticleTypes; import net.minecraft.state.BooleanProperty; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.Hand; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraftforge.common.Tags; public abstract class AbstractChassisBlock extends RotatedPillarBlock implements IWithTileEntity, IBlockWithScrollableValue { - + private static final Vec3d valuePos = new Vec3d(15 / 16f, 9 / 16f, 9 / 16f); public AbstractChassisBlock(Properties properties) { @@ -50,16 +55,24 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock return false; ItemStack heldItem = player.getHeldItem(handIn); - boolean isSlimeBall = heldItem.isItemEqual(new ItemStack(Items.SLIME_BALL)); + boolean isSlimeBall = heldItem.getItem().isIn(Tags.Items.SLIMEBALLS); + if ((!heldItem.isEmpty() || !player.isSneaking()) && !isSlimeBall) return false; if (state.get(affectedSide) == isSlimeBall) return false; - if (worldIn.isRemote) + if (worldIn.isRemote) { + Vec3d vec = hit.getHitVec(); + worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0); return true; + } + worldIn.playSound(null, pos, SoundEvents.BLOCK_SLIME_BLOCK_PLACE, SoundCategory.BLOCKS, .5f, 1); if (isSlimeBall && !player.isCreative()) heldItem.shrink(1); + if (!isSlimeBall && !player.isCreative()) + Block.spawnAsEntity(worldIn, pos.offset(hit.getFace()), new ItemStack(Items.SLIME_BALL)); + worldIn.setBlockState(pos, state.with(affectedSide, isSlimeBall)); return true; } @@ -78,17 +91,17 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock public String getValueName(BlockState state, IWorld world, BlockPos pos) { return Lang.translate("generic.range"); } - + @Override public Vec3d getValueBoxPosition(BlockState state, IWorld world, BlockPos pos) { return valuePos; } - + @Override public Direction getValueBoxDirection(BlockState state, IWorld world, BlockPos pos) { return null; } - + @Override public boolean isValueOnAllSides() { return true; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/receivers/constructs/MechanicalPistonBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/receivers/constructs/MechanicalPistonBlock.java index 32fc8531d..e61db1126 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/receivers/constructs/MechanicalPistonBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/receivers/constructs/MechanicalPistonBlock.java @@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.receivers.constructs; import com.simibubi.create.AllBlocks; import com.simibubi.create.CreateConfig; +import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.contraptions.base.IRotate; import com.simibubi.create.modules.contraptions.base.KineticBlock; @@ -145,7 +146,7 @@ public class MechanicalPistonBlock extends KineticBlock { @Override public String getName() { - return name().toLowerCase(); + return Lang.asId(name()); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java index 905be6235..799ab5847 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java @@ -7,6 +7,7 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.block.IWithoutBlockItem; +import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock; import com.simibubi.create.modules.contraptions.relays.belt.BeltTileEntity.TransportedEntityInfo; @@ -325,7 +326,7 @@ public class BeltBlock extends HorizontalKineticBlock implements IWithoutBlockIt @Override public String getName() { - return name().toLowerCase(); + return Lang.asId(name()); } } @@ -334,7 +335,7 @@ public class BeltBlock extends HorizontalKineticBlock implements IWithoutBlockIt @Override public String getName() { - return name().toLowerCase(); + return Lang.asId(name()); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java index 3c172886e..93bf50e8e 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java @@ -23,6 +23,8 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.DyeColor; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.NBTUtil; +import net.minecraft.potion.EffectInstance; +import net.minecraft.potion.Effects; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; @@ -196,9 +198,10 @@ public class BeltTileEntity extends KineticTileEntity implements ITickableTileEn if (entityIn.posY - .25f < pos.getY()) return; - // Not sure if this does anything - if (entityIn instanceof LivingEntity) - ((LivingEntity) entityIn).setIdleTime(101); + // Lock entities in place + if (entityIn instanceof LivingEntity && !(entityIn instanceof PlayerEntity)) { + ((LivingEntity) entityIn).addPotionEffect(new EffectInstance(Effects.SLOWNESS, 1, 9, false, false)); + } BeltTileEntity belt = (BeltTileEntity) te; diff --git a/src/main/java/com/simibubi/create/modules/curiosities/partialWindows/WindowInABlockModel.java b/src/main/java/com/simibubi/create/modules/curiosities/partialWindows/WindowInABlockModel.java index 1a7203c27..7819c1b1b 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/partialWindows/WindowInABlockModel.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/partialWindows/WindowInABlockModel.java @@ -1,5 +1,9 @@ package com.simibubi.create.modules.curiosities.partialWindows; +import static com.simibubi.create.modules.curiosities.partialWindows.WindowInABlockTileEntity.PARTIAL_BLOCK; +import static com.simibubi.create.modules.curiosities.partialWindows.WindowInABlockTileEntity.POSITION; +import static com.simibubi.create.modules.curiosities.partialWindows.WindowInABlockTileEntity.WINDOW_BLOCK; + import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -23,14 +27,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3i; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.model.data.IModelData; -import net.minecraftforge.client.model.data.ModelProperty; public class WindowInABlockModel extends WrappedBakedModel { - public static final ModelProperty PARTIAL_BLOCK = new ModelProperty<>(); - public static final ModelProperty WINDOW_BLOCK = new ModelProperty<>(); - public static final ModelProperty POSITION = new ModelProperty<>(); - public WindowInABlockModel(IBakedModel template) { super(template); } @@ -46,7 +45,7 @@ public class WindowInABlockModel extends WrappedBakedModel { if (partialState == null || windowState == null) return dispatcher.getModelForState(Blocks.DIRT.getDefaultState()).getQuads(state, side, rand, data); - + BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer(); if (partialState.canRenderInLayer(renderLayer) && partialState != null) { quads.addAll(dispatcher.getModelForState(partialState).getQuads(partialState, side, rand, data)); diff --git a/src/main/java/com/simibubi/create/modules/curiosities/partialWindows/WindowInABlockTileEntity.java b/src/main/java/com/simibubi/create/modules/curiosities/partialWindows/WindowInABlockTileEntity.java index 0a5ca65bf..918286a9e 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/partialWindows/WindowInABlockTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/partialWindows/WindowInABlockTileEntity.java @@ -1,8 +1,5 @@ package com.simibubi.create.modules.curiosities.partialWindows; -import static com.simibubi.create.modules.curiosities.partialWindows.WindowInABlockModel.PARTIAL_BLOCK; -import static com.simibubi.create.modules.curiosities.partialWindows.WindowInABlockModel.WINDOW_BLOCK; - import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.SyncedTileEntity; @@ -14,18 +11,22 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelDataMap; +import net.minecraftforge.client.model.data.ModelProperty; public class WindowInABlockTileEntity extends SyncedTileEntity { private BlockState partialBlock = Blocks.AIR.getDefaultState(); private BlockState windowBlock = Blocks.AIR.getDefaultState(); + private IModelData modelData; + public static final ModelProperty PARTIAL_BLOCK = new ModelProperty<>(); + public static final ModelProperty WINDOW_BLOCK = new ModelProperty<>(); + public static final ModelProperty POSITION = new ModelProperty<>(); public WindowInABlockTileEntity() { super(AllTileEntities.WINDOW_IN_A_BLOCK.type); modelData = new ModelDataMap.Builder().withInitial(WINDOW_BLOCK, Blocks.AIR.getDefaultState()) - .withInitial(PARTIAL_BLOCK, Blocks.AIR.getDefaultState()) - .withInitial(WindowInABlockModel.POSITION, BlockPos.ZERO).build(); + .withInitial(PARTIAL_BLOCK, Blocks.AIR.getDefaultState()).withInitial(POSITION, BlockPos.ZERO).build(); } @Override @@ -59,9 +60,9 @@ public class WindowInABlockTileEntity extends SyncedTileEntity { @Override public IModelData getModelData() { - modelData.setData(WindowInABlockModel.PARTIAL_BLOCK, partialBlock); - modelData.setData(WindowInABlockModel.WINDOW_BLOCK, windowBlock); - modelData.setData(WindowInABlockModel.POSITION, pos); + modelData.setData(PARTIAL_BLOCK, partialBlock); + modelData.setData(WINDOW_BLOCK, windowBlock); + modelData.setData(POSITION, pos); return modelData; } diff --git a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunItem.java b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunItem.java index 5ce44020e..78469dcfa 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunItem.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunItem.java @@ -66,9 +66,7 @@ import net.minecraftforge.fml.network.PacketDistributor; public class BuilderGunItem extends Item { public static enum ComponentTier { - None(TextFormatting.DARK_GRAY), - BlazeBrass(TextFormatting.GOLD), - ChorusChrome(TextFormatting.LIGHT_PURPLE), + None(TextFormatting.DARK_GRAY), BlazeBrass(TextFormatting.GOLD), ChorusChrome(TextFormatting.LIGHT_PURPLE), ; @@ -108,9 +106,9 @@ public class BuilderGunItem extends Item { for (Components c : Components.values()) { ComponentTier tier = getTier(c, stack); ItemDescription.add(tooltip, - "> " + TextFormatting.GRAY + Lang.translate("blockzapper.component." + c.name().toLowerCase()) + "> " + TextFormatting.GRAY + Lang.translate("blockzapper.component." + Lang.asId(c.name())) + ": " + tier.color - + Lang.translate("blockzapper.componentTier." + tier.name().toLowerCase())); + + Lang.translate("blockzapper.componentTier." + Lang.asId(tier.name()))); } } } diff --git a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunUpgradeRecipe.java b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunUpgradeRecipe.java index bef5ef878..a4df1bd67 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunUpgradeRecipe.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunUpgradeRecipe.java @@ -10,9 +10,11 @@ import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.ICraftingRecipe; import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.ShapedRecipe; import net.minecraft.network.PacketBuffer; import net.minecraft.util.JSONUtils; +import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistryEntry; @@ -33,7 +35,12 @@ public class BuilderGunUpgradeRecipe implements ICraftingRecipe { public boolean matches(CraftingInventory inv, World worldIn) { return getRecipe().matches(inv, worldIn); } - + + @Override + public NonNullList getIngredients() { + return recipe.getIngredients(); + } + @Override public ItemStack getCraftingResult(CraftingInventory inv) { for (int slot = 0; slot < inv.getSizeInventory(); slot++) { diff --git a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/PlacementPatterns.java b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/PlacementPatterns.java index 639bb7ed3..2cdf9678d 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/PlacementPatterns.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/PlacementPatterns.java @@ -1,6 +1,7 @@ package com.simibubi.create.modules.curiosities.placementHandgun; import com.simibubi.create.ScreenResources; +import com.simibubi.create.foundation.utility.Lang; public enum PlacementPatterns { @@ -15,7 +16,7 @@ public enum PlacementPatterns { public ScreenResources icon; private PlacementPatterns(ScreenResources icon) { - this.translationKey = name().toLowerCase(); + this.translationKey = Lang.asId(name()); this.icon = icon; } diff --git a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandItem.java b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandItem.java index 299a43217..ecfa4382a 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandItem.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandItem.java @@ -60,7 +60,7 @@ public class SymmetryWandItem extends Item { if (player.isSneaking()) { if (player.world.isRemote) { DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { - openWandGUI(wand); + openWandGUI(wand, context.getHand()); }); player.getCooldownTracker().setCooldown(this, 5); } @@ -123,7 +123,7 @@ public class SymmetryWandItem extends Item { if (playerIn.isSneaking()) { if (worldIn.isRemote) { DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { - openWandGUI(playerIn.getHeldItem(handIn)); + openWandGUI(playerIn.getHeldItem(handIn), handIn); }); playerIn.getCooldownTracker().setCooldown(this, 5); } @@ -136,8 +136,8 @@ public class SymmetryWandItem extends Item { } @OnlyIn(Dist.CLIENT) - private void openWandGUI(ItemStack wand) { - ScreenOpener.open(new SymmetryWandScreen(wand)); + private void openWandGUI(ItemStack wand, Hand hand) { + ScreenOpener.open(new SymmetryWandScreen(wand, hand)); } private static void checkNBT(ItemStack wand) { diff --git a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java index 674fb3cea..e3cbde8ee 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java @@ -43,14 +43,16 @@ public class SymmetryWandScreen extends AbstractSimiScreen { private SymmetryMirror currentElement; private float animationProgress; private ItemStack wand; + private Hand hand; - public SymmetryWandScreen(ItemStack wand) { + public SymmetryWandScreen(ItemStack wand, Hand hand) { super(); currentElement = SymmetryWandItem.getMirror(wand); if (currentElement instanceof EmptyMirror) { currentElement = new PlaneMirror(Vec3d.ZERO); } + this.hand = hand; this.wand = wand; animationProgress = 0; } @@ -170,12 +172,12 @@ public class SymmetryWandScreen extends AbstractSimiScreen { @Override public void removed() { - ItemStack heldItemMainhand = minecraft.player.getHeldItemMainhand(); - CompoundNBT compound = heldItemMainhand.getTag(); + ItemStack heldItem = minecraft.player.getHeldItem(hand); + CompoundNBT compound = heldItem.getTag(); compound.put(SymmetryWandItem.SYMMETRY, currentElement.writeToNbt()); - heldItemMainhand.setTag(compound); - AllPackets.channel.send(PacketDistributor.SERVER.noArg(), new NbtPacket(heldItemMainhand)); - minecraft.player.setHeldItem(Hand.MAIN_HAND, heldItemMainhand); + heldItem.setTag(compound); + AllPackets.channel.send(PacketDistributor.SERVER.noArg(), new NbtPacket(heldItem, hand)); + minecraft.player.setHeldItem(hand, heldItem); super.removed(); } diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/EntityDetectorBlock.java b/src/main/java/com/simibubi/create/modules/logistics/block/EntityDetectorBlock.java index d6b9e8d7f..d159a0235 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/block/EntityDetectorBlock.java +++ b/src/main/java/com/simibubi/create/modules/logistics/block/EntityDetectorBlock.java @@ -30,8 +30,8 @@ import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; -import net.minecraft.util.Hand; import net.minecraft.util.Direction.Axis; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.Vec3d; diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/LinkedExtractorBlock.java b/src/main/java/com/simibubi/create/modules/logistics/block/LinkedExtractorBlock.java index 6774d518d..f3f86c89c 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/block/LinkedExtractorBlock.java +++ b/src/main/java/com/simibubi/create/modules/logistics/block/LinkedExtractorBlock.java @@ -14,8 +14,8 @@ import net.minecraft.item.BlockItemUseContext; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.Direction; -import net.minecraft.util.Hand; import net.minecraft.util.Direction.Axis; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.Vec3d; diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/diodes/ConfigureFlexpeaterPacket.java b/src/main/java/com/simibubi/create/modules/logistics/block/diodes/ConfigureFlexpeaterPacket.java index 75431b3b6..b68759606 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/block/diodes/ConfigureFlexpeaterPacket.java +++ b/src/main/java/com/simibubi/create/modules/logistics/block/diodes/ConfigureFlexpeaterPacket.java @@ -33,7 +33,9 @@ public class ConfigureFlexpeaterPacket extends TileEntityConfigurationPacket(); gathered = new HashMap<>(); } - + public void warnBlockNotLoaded() { blocksNotLoaded = true; } - + public void require(Item item) { if (required.containsKey(item)) required.put(item, required.get(item) + 1); - else + else required.put(item, 1); } - + public void collect(ItemStack stack) { Item item = stack.getItem(); if (required.containsKey(item)) if (gathered.containsKey(item)) gathered.put(item, gathered.get(item) + stack.getCount()); - else + else gathered.put(item, stack.getCount()); } @@ -55,44 +56,47 @@ public class MaterialChecklist { int itemsWritten = 0; StringBuilder string = new StringBuilder("{\"text\":\""); - + if (blocksNotLoaded) { - string.append("\n" + TextFormatting.RED + "* Disclaimer *\n\n"); - string.append("Material List may be inaccurate due to relevant chunks not being loaded."); + string.append("\n" + TextFormatting.RED + "* Disclaimer *\n\n"); + string.append("Material List may be inaccurate due to relevant chunks not being loaded."); string.append("\"}"); pages.add(new StringNBT(string.toString())); string = new StringBuilder("{\"text\":\""); } - + List keys = new ArrayList<>(required.keySet()); Collections.sort(keys, (item1, item2) -> { - String name1 = new TranslationTextComponent(((Item) item1).getTranslationKey()).getFormattedText().toLowerCase(); - String name2 = new TranslationTextComponent(((Item) item2).getTranslationKey()).getFormattedText().toLowerCase(); + Locale locale = Locale.ENGLISH; + String name1 = new TranslationTextComponent(((Item) item1).getTranslationKey()).getFormattedText() + .toLowerCase(locale); + String name2 = new TranslationTextComponent(((Item) item2).getTranslationKey()).getFormattedText() + .toLowerCase(locale); return name1.compareTo(name2); }); - + List completed = new ArrayList<>(); for (Item item : keys) { int amount = required.get(item); if (gathered.containsKey(item)) amount -= gathered.get(item); - + if (amount <= 0) { completed.add(item); continue; } - + if (itemsWritten == 6) { itemsWritten = 0; string.append("\"}"); pages.add(new StringNBT(string.toString())); string = new StringBuilder("{\"text\":\""); } - + itemsWritten++; string.append(unfinishedEntry(new ItemStack(item), amount)); } - + for (Item item : completed) { if (itemsWritten == 6) { itemsWritten = 0; @@ -100,11 +104,11 @@ public class MaterialChecklist { pages.add(new StringNBT(string.toString())); string = new StringBuilder("{\"text\":\""); } - + itemsWritten++; string.append(gatheredEntry(new ItemStack(item), required.get(item))); } - + string.append("\"}"); pages.add(new StringNBT(string.toString())); @@ -120,16 +124,16 @@ public class MaterialChecklist { int stacks = amount / 64; int remainder = amount % 64; ITextComponent tc = new TranslationTextComponent(item.getTranslationKey()); - return TextFormatting.DARK_GREEN + tc.getFormattedText() - + " \\u2714\n x" + amount + TextFormatting.GRAY + " | " + stacks + "\\u25A4 +" + remainder + "\n"; + return TextFormatting.DARK_GREEN + tc.getFormattedText() + " \\u2714\n x" + amount + TextFormatting.GRAY + " | " + + stacks + "\\u25A4 +" + remainder + "\n"; } private String unfinishedEntry(ItemStack item, int amount) { int stacks = amount / 64; int remainder = amount % 64; ITextComponent tc = new TranslationTextComponent(item.getTranslationKey()); - return TextFormatting.BLUE + tc.getFormattedText() + "\n x" + amount - + TextFormatting.GRAY + " | " + stacks + "\\u25A4 +" + remainder + "\n"; + return TextFormatting.BLUE + tc.getFormattedText() + "\n x" + amount + TextFormatting.GRAY + " | " + stacks + + "\\u25A4 +" + remainder + "\n"; } } diff --git a/src/main/java/com/simibubi/create/modules/schematics/SchematicWorld.java b/src/main/java/com/simibubi/create/modules/schematics/SchematicWorld.java index e57670ba3..d780187e2 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/SchematicWorld.java +++ b/src/main/java/com/simibubi/create/modules/schematics/SchematicWorld.java @@ -3,12 +3,11 @@ package com.simibubi.create.modules.schematics; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Random; import java.util.Set; import java.util.function.Predicate; -import com.google.common.collect.ImmutableMap; import com.simibubi.create.foundation.type.Cuboid; +import com.simibubi.create.foundation.utility.WrappedWorld; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -16,47 +15,34 @@ import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; import net.minecraft.fluid.IFluidState; -import net.minecraft.particles.IParticleData; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.DifficultyInstance; import net.minecraft.world.EmptyTickList; import net.minecraft.world.ITickList; -import net.minecraft.world.IWorld; import net.minecraft.world.LightType; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; -import net.minecraft.world.border.WorldBorder; -import net.minecraft.world.chunk.AbstractChunkProvider; -import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.dimension.Dimension; -import net.minecraft.world.gen.Heightmap.Type; -import net.minecraft.world.storage.WorldInfo; -public class SchematicWorld implements IWorld { +public class SchematicWorld extends WrappedWorld { private Map blocks; private Cuboid bounds; public BlockPos anchor; - - public SchematicWorld(Map blocks, Cuboid bounds, BlockPos anchor) { + + public SchematicWorld(Map blocks, Cuboid bounds, BlockPos anchor, World original) { + super(original); this.blocks = blocks; this.setBounds(bounds); this.anchor = anchor; } - + public Set getAllPositions() { return blocks.keySet(); } - + @Override public TileEntity getTileEntity(BlockPos pos) { return null; @@ -65,11 +51,11 @@ public class SchematicWorld implements IWorld { @Override public BlockState getBlockState(BlockPos globalPos) { BlockPos pos = globalPos.subtract(anchor); - + if (pos.getY() - bounds.y == -1) { return Blocks.GRASS_BLOCK.getDefaultState(); } - + if (getBounds().contains(pos) && blocks.containsKey(pos)) { return blocks.get(pos); } else { @@ -83,7 +69,7 @@ public class SchematicWorld implements IWorld { @Override public IFluidState getFluidState(BlockPos pos) { - return new FluidState(Fluids.EMPTY, ImmutableMap.of()); + return getBlockState(pos).getFluidState(); } @Override @@ -117,46 +103,11 @@ public class SchematicWorld implements IWorld { return 0; } - @Override - public IChunk getChunk(int x, int z, ChunkStatus requiredStatus, boolean nonnull) { - return null; - } - - @Override - public BlockPos getHeight(Type heightmapType, BlockPos pos) { - return BlockPos.ZERO; - } - - @Override - public int getHeight(Type heightmapType, int x, int z) { - return 0; - } - @Override public int getSkylightSubtracted() { return 0; } - @Override - public WorldBorder getWorldBorder() { - return null; - } - - @Override - public boolean isRemote() { - return false; - } - - @Override - public int getSeaLevel() { - return 0; - } - - @Override - public Dimension getDimension() { - return null; - } - @Override public boolean hasBlockState(BlockPos pos, Predicate predicate) { return predicate.test(getBlockState(pos)); @@ -197,16 +148,11 @@ public class SchematicWorld implements IWorld { if (boundsMax.getZ() <= pos.getZ()) { bounds.length += pos.getZ() - boundsMax.getZ() + 1; } - + blocks.put(pos, arg1); return true; } - @Override - public long getSeed() { - return 0; - } - @Override public ITickList getPendingBlockTicks() { return EmptyTickList.get(); @@ -217,54 +163,6 @@ public class SchematicWorld implements IWorld { return EmptyTickList.get(); } - @Override - public World getWorld() { - return null; - } - - @Override - public WorldInfo getWorldInfo() { - return null; - } - - @Override - public DifficultyInstance getDifficultyForLocation(BlockPos pos) { - return null; - } - - @Override - public AbstractChunkProvider getChunkProvider() { - return null; - } - - @Override - public Random getRandom() { - return new Random(); - } - - @Override - public void notifyNeighbors(BlockPos pos, Block blockIn) { - } - - @Override - public BlockPos getSpawnPoint() { - return null; - } - - @Override - public void playSound(PlayerEntity player, BlockPos pos, SoundEvent soundIn, SoundCategory category, float volume, - float pitch) { - } - - @Override - public void addParticle(IParticleData particleData, double x, double y, double z, double xSpeed, double ySpeed, - double zSpeed) { - } - - @Override - public void playEvent(PlayerEntity player, int type, BlockPos pos, int data) { - } - public Cuboid getBounds() { return bounds; } diff --git a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonTileEntity.java index 5b7141296..5bb0b2674 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonTileEntity.java @@ -535,7 +535,7 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka } schematicAnchor = anchor; - blockReader = new SchematicWorld(new HashMap<>(), new Cuboid(), schematicAnchor); + blockReader = new SchematicWorld(new HashMap<>(), new Cuboid(), schematicAnchor, world); activeTemplate.addBlocksToWorld(blockReader, schematicAnchor, SchematicItem.getSettings(blueprint)); schematicLoaded = true; state = State.PAUSED; diff --git a/src/main/java/com/simibubi/create/modules/schematics/client/SchematicHandler.java b/src/main/java/com/simibubi/create/modules/schematics/client/SchematicHandler.java index b455dad32..6a406a721 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/client/SchematicHandler.java +++ b/src/main/java/com/simibubi/create/modules/schematics/client/SchematicHandler.java @@ -209,7 +209,7 @@ public class SchematicHandler { if (schematic.getSize().equals(BlockPos.ZERO)) return; - SchematicWorld w = new SchematicWorld(new HashMap<>(), new Cuboid(), anchor); + SchematicWorld w = new SchematicWorld(new HashMap<>(), new Cuboid(), anchor, Minecraft.getInstance().world); PlacementSettings settings = cachedSettings.copy(); settings.setBoundingBox(null); schematic.addBlocksToWorld(w, anchor, settings); diff --git a/src/main/java/com/simibubi/create/modules/schematics/client/SchematicHologram.java b/src/main/java/com/simibubi/create/modules/schematics/client/SchematicHologram.java index b8934f0c9..8f5f13f4b 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/client/SchematicHologram.java +++ b/src/main/java/com/simibubi/create/modules/schematics/client/SchematicHologram.java @@ -49,7 +49,8 @@ public class SchematicHologram { } public void startHologram(Template schematic, BlockPos anchor) { - SchematicWorld world = new SchematicWorld(new HashMap<>(), new Cuboid(BlockPos.ZERO, BlockPos.ZERO), anchor); + SchematicWorld world = new SchematicWorld(new HashMap<>(), new Cuboid(BlockPos.ZERO, BlockPos.ZERO), anchor, + Minecraft.getInstance().world); schematic.addBlocksToWorld(world, anchor, new PlacementSettings()); startHologram(world); } diff --git a/src/main/java/com/simibubi/create/modules/schematics/client/tools/Tools.java b/src/main/java/com/simibubi/create/modules/schematics/client/tools/Tools.java index 2b6965d2b..52790f748 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/client/tools/Tools.java +++ b/src/main/java/com/simibubi/create/modules/schematics/client/tools/Tools.java @@ -29,7 +29,7 @@ public enum Tools { } public String getDisplayName() { - return Lang.translate("schematic.tool." + name().toLowerCase()); + return Lang.translate("schematic.tool." + Lang.asId(name())); } public ScreenResources getIcon() { @@ -45,7 +45,7 @@ public enum Tools { } public List getDescription() { - return Lang.translatedOptions("schematic.tool." + name().toLowerCase() + ".description", "0", "1", "2", "3"); + return Lang.translatedOptions("schematic.tool." + Lang.asId(name()) + ".description", "0", "1", "2", "3"); } } diff --git a/src/main/resources/assets/create/textures/gui/recipes3.png b/src/main/resources/assets/create/textures/gui/recipes3.png index c299dda80..2012b71db 100644 Binary files a/src/main/resources/assets/create/textures/gui/recipes3.png and b/src/main/resources/assets/create/textures/gui/recipes3.png differ diff --git a/src/main/resources/data/create/recipes/crafting/encased_fan.json b/src/main/resources/data/create/recipes/crafting/encased_fan.json index 5c57844f9..ae505f03e 100644 --- a/src/main/resources/data/create/recipes/crafting/encased_fan.json +++ b/src/main/resources/data/create/recipes/crafting/encased_fan.json @@ -10,7 +10,7 @@ "item": "minecraft:iron_bars" }, "A": { - "item": "create:iron_sheet" + "item": "create:andesite_alloy_cube" }, "S": { "item": "create:propeller" diff --git a/src/main/resources/data/create/recipes/crafting/slime_ball.json b/src/main/resources/data/create/recipes/crafting/slime_ball.json new file mode 100644 index 000000000..2e8885ce7 --- /dev/null +++ b/src/main/resources/data/create/recipes/crafting/slime_ball.json @@ -0,0 +1,21 @@ +{ + "type": "crafting_shapeless", + "ingredients": [ + { + "tag": "forge:dyes/lime" + }, + { + "item": "create:dough" + } + ], + "result": { + "item": "minecraft:slime_ball", + "count": 1 + }, + "conditions": [ + { + "type": "create:module", + "module": "contraptions" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/crafting/tree_fertilizer.json b/src/main/resources/data/create/recipes/crafting/tree_fertilizer.json index 2292bf0dc..20dad4a67 100644 --- a/src/main/resources/data/create/recipes/crafting/tree_fertilizer.json +++ b/src/main/resources/data/create/recipes/crafting/tree_fertilizer.json @@ -1,9 +1,23 @@ { "type": "crafting_shapeless", "ingredients": [ - { - "item": "minecraft:horn_coral" - }, + [ + { + "item": "minecraft:horn_coral" + }, + { + "item": "minecraft:tube_coral" + }, + { + "item": "minecraft:fire_coral" + }, + { + "item": "minecraft:bubble_coral" + }, + { + "item": "minecraft:brain_coral" + } + ], { "item": "minecraft:bone_meal" },